更改matplotlib 3D p的轴平面的背景色

2024-10-01 00:30:50 发布

您现在位置:Python中文网/ 问答频道 /正文

在matplotlib的scatterplot example基础上,如何更改三轴网格平面的灰色背景色?我想将其设置为白色,保留默认灰色的网格线。 我找到了this question,但无法将其应用于示例。 谢谢。


Tags: 网格示例matplotlibexamplethis基础平面question
2条回答

用同样的例子。您可以使用set_pane_color方法设置窗格颜色,如下所述http://matplotlib.org/mpl_toolkits/mplot3d/api.html#axis3d。可以使用RGBA元组设置颜色:

# scatter3d_demo.py
# ...
# Set the background color of the pane YZ
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
plt.show()

对于稍有不同的方法,请参见以下内容:

# Get rid of colored axes planes
# First remove fill
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False

# Now set color to white (or whatever is "invisible")
ax.xaxis.pane.set_edgecolor('w')
ax.yaxis.pane.set_edgecolor('w')
ax.zaxis.pane.set_edgecolor('w')

# Bonus: To get rid of the grid as well:
ax.grid(False)

看这个blog post,我用它作为我的来源。

相关问题 更多 >