I have code which makes a plot of a two-dimensional array. Along the x-axis is just the index of my array, but I would like the x-axis to display the value that index represents.
Relevant code:
plt.imshow(data, aspect="auto")
plt.colorbar()
plt.show()
Where “data” is a 1000 by 200 array. So at the moment, the plot is created correctly, and the x-axis shows the index number of array (0-199).
But this index also corresponds to a date in another list that I have (date[]) of length 200. I want the date corresponding to the index to show on the x-axis, and not the index itself.
How can I fix this?
To put the x-ticks and the labels you can use
However the above will put too many ticks and labels. If you want to reduce the number of ticks to say 5, you can use