Just call the plt.xticks and plt.yticks functions.
First you have to choose where you want your ticks to be on the axis, and then you have to set the labels.
For example: suppose you have an x
axis that spans from 5
to 25
and you want 3 ticks at 8
, 15
and 22
, and you want labels foo
, bar
, baz
.
Then you should call:
# do your plotting first, for example
x = np.arange(5, 25)
y = x * x
plt.plot(x, y)
# and then the ticks
plt.xticks([8, 15, 22], ['foo', 'bar', 'baz'])
# And finally show the plot
plt.show()
In your case, since your labels ticks are at [0, 1, 2]
and you want hello
, apple
and orange
as your labels. You should do:
plt.xticks([0, 1, 2], ['hello', 'apple', 'orange'])