如何仅对matplotlib体素上的外部边缘着色?

问题描述

我想使用体素在matplotlib中绘制一个(20,20,20)的立方体,该立方体具有一种颜色的面和另一种颜色的边缘。但是,当我使用edgecolors函数时,它需要一个网格(20x20x20),而不仅是立方体的边缘。我如何只给没有网格的边缘着色? 预先感谢。

我做了以下事情:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

#Create a figure
fig = plt.figure()

#Create a subplot for that figure
ax = fig.add_subplot(111,projection='3d')

#Define limit of axis
ax = Axes3D(fig)
ax.set_xlim3d(40,110)
ax.set_ylim3d(40,110)
ax.set_zlim3d(40,110)

#Draw a cube
n_voxels = np.zeros((19,19,19),dtype=bool)

facecolors = np.where(n_voxels,'#FFD65DC0','#0576EC33')
edgecolors = np.where(n_voxels,'#000000','#000000')
filled = np.ones(n_voxels.shape)

ax = fig.gca(projection='3d')
ax.voxels(x,y,z,filled,facecolors=facecolors,edgecolors=edgecolors)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)