更改3D图形颜色(matplotlib) [英] Change 3D Graph Color (matplotlib)

查看:1009
本文介绍了更改3D图形颜色(matplotlib)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用以下代码在matplotlib中绘制了3D图形:

I have plotted a 3D graph in matplotlib using the following code:

#Previously defines lists of data to plot...
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')

ax.set_axis_bgcolor('black')
ax.xaxis.label.set_color('white')
ax.yaxis.label.set_color('white')
ax.zaxis.label.set_color('white')
ax.tick_params(axis='x',colors='white')
ax.tick_params(axis='y',colors='white')
ax.tick_params(axis='z',colors='white')

ax.scatter(swasp_mag1,swasp_per1,swasp_age1,edgecolor='none',c='r',marker='o',s=35,label='SWASP')
ax.scatter(hyd_mag1,hyd_per1,hyd_age1,edgecolor='none',c='y',marker='o',s=35,label='Hyades')
ax.scatter(pld_mag1,pld_per1,pld_age1,edgecolor='none',c='b',marker='o',s=35,label='Pleiades')

ax.set_xlabel('B-V [mag]')
ax.set_ylabel('Period [days]')
ax.set_zlabel('Age [Myr]')

ax.set_xlim(0.495,1.6)
ax.set_ylim(0,30)
ax.set_zlim(0,600)

ax.legend(scatterpoints=1)
plt.show()

运行该程序时,我得到以下结果:

When I run this program I get the following result:

我将背景更改为黑色,而将刺更改为白色(如图中所示),但是我想更改飞机的颜色(图像中的灰色区域).我已经研究过,但还没有找到一种方法来做到这一点.有什么办法可以改变3D matplotlib图形中平面的颜色?

I have changed the background to black and the spines to white (as seen in the image), but I would like to change the color of the planes (the gray area in the image). I have researched but have not found a way to do this. Is there any way I can change the color of the planes in a 3D matplotlib graph?

推荐答案

请参见您要查找的函数称为set_pane_color(),它是axis3d类的成员,因此您可以这样称呼它:

The function that you are looking for is called set_pane_color(), it is a member of the axis3d class, so you'd call it as such:

ax.w_xaxis.set_pane_color((R,G,B,A))
ax.w_yaxis.set_pane_color((R,G,B,A))
ax.w_zaxis.set_pane_color((R,G,B,A))

http://matplotlib.org/mpl_toolkits/mplot3d/api.html#mpl_toolkits.mplot3d.axis3d.Axis.set_pane_color

这篇关于更改3D图形颜色(matplotlib)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆