Hide axis values but keep axis tick labels in matplotlib
If you use the matplotlib object-oriented approach, this is a simple task using ax.set_xticklabels()
and ax.set_yticklabels()
:
import matplotlib.pyplot as plt
# Create Figure and Axes instances
fig,ax = plt.subplots(1)
# Make your plot, set your axes labels
ax.plot(sim_1['t'],sim_1['V'],'k')
ax.set_ylabel('V')
ax.set_xlabel('t')
# Turn off tick labels
ax.set_yticklabels([])
ax.set_xticklabels([])
plt.show()
Without a subplots
, you can universally remove the ticks like this:
plt.xticks([])
plt.yticks([])
This works great. Just paste this before plt.show()
:
plt.gca().axes.get_yaxis().set_visible(False)
Boom.