How to hide axes and grids in matplotlib (python)

I would like to be able to hide the axes and grid lines in a 3D matplotlib plot. I want to do this because when zooming in and out, the image becomes quite unpleasant. I'm not sure which 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 a plot I'm looking at:
This is an example of the plot that I am looking at

+6
source share
2 answers
# Hide grid lines
ax.grid(False)

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

Please note: you need to use matplotlib> = 1.2 for set_zticks().

+13
source

Turn the axis with:

plt.axis('off')

And grids with:

ax.grid(False)
+7
source

All Articles