如何在Matplotlib中隐藏轴和网格线(Python) [英] How to hide axes and gridlines in Matplotlib (python)

查看:255
本文介绍了如何在Matplotlib中隐藏轴和网格线(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够隐藏3D matplotlib图上的轴和网格线.我想这样做是因为放大和缩小图像时会很讨厌.我不确定要在此处包括哪些代码,但这是我用来创建图形的代码.

I would like to be able to hide the axes and gridlines on a 3D matplotlib graph. I want to do this because when zooming in and out the image gets pretty nasty. I'm not sure what code to include here but this is what I use to create the graph.

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.view_init(30, -90)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
plt.xlim(0,pL)
plt.ylim(0,pW)
ax.set_aspect("equal")

plt.show()

这是我正在查看的情节的示例:

This is an example of the plot that I am looking at:

推荐答案

# Hide grid lines
ax.grid(False)

# Hide axes ticks
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])

注意,要使set_zticks()工作,您需要matplotlib> = 1.2.

Note, you need matplotlib>=1.2 for set_zticks() to work.

这篇关于如何在Matplotlib中隐藏轴和网格线(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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