How to hide axes and gridlines in Matplotlib (python)

PythonMatplotlib

Python Problem Overview


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:
This is an example of the plot that I am looking at

Python Solutions


Solution 1 - Python

# Hide grid lines
ax.grid(False)

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

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

Solution 2 - Python

Turn the axes off with:

plt.axis('off')

And gridlines with:

plt.grid(b=None)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex SantelleView Question on Stackoverflow
Solution 1 - PythonazaleaView Answer on Stackoverflow
Solution 2 - PythonJohnnyh101View Answer on Stackoverflow