0

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

enter image description here

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

Dan
  • 3,647
  • 5
  • 20
  • 26
DHJ
  • 611
  • 2
  • 13
  • Does this answer your question? [Hide tick label values but keep axis labels](https://stackoverflow.com/questions/37039685/hide-tick-label-values-but-keep-axis-labels) – Edward Ji May 28 '22 at 14:19

1 Answers1

2

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([])
Edward Ji
  • 745
  • 8
  • 19