I have this image:
JavaScript
x
5
1
plt.plot(sim_1['t'],sim_1['V'],'k')
2
plt.ylabel('V')
3
plt.xlabel('t')
4
plt.show()
5
I want to hide the numbers; if I use:
JavaScript
1
2
1
plt.axis('off')
2
…I get this image:
It also hide the labels, V
and t
. How can I keep the labels while hiding the values?
Advertisement
Answer
If you use the matplotlib object-oriented approach, this is a simple task using ax.set_xticklabels()
and ax.set_yticklabels()
. Here we can just set them to an empty list to remove any labels:
JavaScript
1
16
16
1
import matplotlib.pyplot as plt
2
3
# Create Figure and Axes instances
4
fig,ax = plt.subplots(1)
5
6
# Make your plot, set your axes labels
7
ax.plot(sim_1['t'],sim_1['V'],'k')
8
ax.set_ylabel('V')
9
ax.set_xlabel('t')
10
11
# Turn off tick labels
12
ax.set_yticklabels([])
13
ax.set_xticklabels([])
14
15
plt.show()
16
If you also want to remove the tick marks as well as the labels, you can use ax.set_xticks()
and ax.set_yticks()
and set those to an empty list as well:
JavaScript
1
3
1
ax.set_xticks([])
2
ax.set_yticks([])
3