Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove axis values in matplotlib 3d plot

How do I remove the axis values in a matplotlib 3d plot? A random plot:

import numpy as np
import matplotlib.pyplot as plt



ax = plt.axes(projection='3d')
a = .6
b = 1.2


zline = np.linspace(0, 15, 1000)
xline = zline*.6
yline = zline*1.2
ax.plot3D(xline, yline, zline, 'gray')


zdata = 15 * np.random.random(100)
xdata = zdata*.6 + 2 * np.random.randn(100)
ydata = zdata*1.2 + 1 * np.random.randn(100)
ax.scatter3D(xdata, ydata, zdata, c='red')


w = (1.0, 1.0, 1.0, 1.0)
ax.w_xaxis.set_pane_color(w)
ax.w_yaxis.set_pane_color(w)
ax.w_zaxis.set_pane_color(w)
plt.show()

enter image description here

If I use ax.set_xticks([]) for all axes I get

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

I still want to keep the lines in the plot and only remove the axis values.

>Solution :

You can set the tick labels. Add the following lines before plt.show().

ax.axes.xaxis.set_ticklabels([])
ax.axes.yaxis.set_ticklabels([])
ax.axes.zaxis.set_ticklabels([])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading