繁体   English   中英

更改 matplotlib 3D 绘图轴平面的背景颜色

[英]Changing the background color of the axes planes of a matplotlib 3D plot

基于matplotlib的散点图示例,如何更改3轴网格平面的灰色背景色? 我想将它设置为白色,保持网格线为默认的灰色。 我发现了这个问题,但我无法将其应用于示例。 谢谢。

使用相同的示例。 您可以使用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)

请参阅我用作来源的这篇博文

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM