我正在使用matplotlib为数组绘制3D条形图.我需要给这些栏杆加上一种边框 colored颜色 .但是,边 colored颜色 将0.0值数据点着色为黑色.有没有办法不给这些数据点涂上 colored颜色 ?我try 在值为0.0时通过循环执行edgecolors=None.然而,这似乎无济于事.如果有任何帮助,我很感激.
我用来策划的 playbook ,
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
lx= len(r[0])
ly= len(r[:,0])
xpos = np.arange(0,lx,1)
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.25, ypos+0.25)
xpos = xpos.flatten()
ypos = ypos.flatten()
zpos = np.zeros(lx*ly)
cs = ['r', 'g', 'b', 'y', 'c'] * ly
edgecolor_store = []
dx = 0.5 * np.ones_like(zpos)
dy = 0 * np.ones_like(zpos)
#dz = zpos
dz = r.flatten()
for value in dz:
if value == 0.0:
edgecolor_store.append('none')
if value > 0.0:
edgecolor_store.append('black')
mask_dz = dz == 0 # SO:60111736, 3d case
#print(dz)
ax.bar3d(xpos,ypos,zpos, dx, dy,dz,color=cs,zsort='average',alpha=0.5,edgecolors=edgecolor_store)
我使用的样本数据,
[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 0. , 0. , 0. ],[ 0. , 0. , 20.7, 0. , 0. ],[ 0.6, 0. , 0.1, 0. , 0.2],[ 0. , 24.8, 0. , 46.7, 0. ],[ 0. , 0. , 99.7, 17.1, 99.3],[ 0. , 12.8, 98.6, 0. , 6.7],[ 0.2, 0. , 0. , 12.6, 0. ]
我得到的输出曲线图是,