In Python, I have a 2D array, e.g.:
1.3 5.7 3.2
5.6 2.3 9.5
1.1 4.1 5.2
I then used ‘imshow’ to get what I needed – I essentially had a plot where the x axis was:
(column) 0 (column) 1 (column) 2 ….
and the y axis was:
.
.
(row) 2
(row) 1
(row) 0
and then the actual values (5.6 or 2.3 or whatever) were represented by colours, which was just what I wanted.
But then later, instead of the x axis just being column 0 column 1 and column 2 etc., I wanted the x axis to show the date which corresponds to column 0 column 1 and column 2 etc.. This information was stored in a different list, say “date_info[]”.
So instead of an arbitrary indexing scheme on the bottom, I want the x values of the imshow to correspond to the values of the date_info[] list – instead of the number 2 for example, I wanted date_info[2] on the x axis.
Now with the help of this forum, I was able to do this using:
plt.xticks(mjdaxis,[int(np.floor(data_info[i])) for i in mjdaxis])
which was sufficient for a while, but I am just changing the labels of the x axis here right? rather than what is being plotted. Now when I am trying to lay one other plot (just a regular curve) on top of my original, the x axis scaling gets messed up, and my columns get bunched up as (1,2,3…) again, instead of their corresponding date_info values (55500, 55530, 55574…)
If anyone can make any sense of what I am saying, that would be great!!
For reference, here is the code that I am now trying:
fig = plt.figure()
ax1 = fig.add_subplot(111)
mjdaxis=np.linspace(0,date_info[0]-1,20).astype('int')
ax1.set_xticks(mjdaxis,[int(np.floor(date_info[i])) for i in mjdaxis])
ax1.imshow(residuals, aspect="auto")
ax2 = ax1.twinx()
ax2.plot(pdot[8:,0],pdot[8:,1])
plt.show()
If I understand you correctly, you should be able to just add the line
ax2.set_xticks([])before yourplt.show(). You might also want to read up on the kwarghold.