I have a 2-d array that I want to display as an image. The dimensions being Y x X(log tau vs arcsec).
The issue is the y axis (log tau) is not evenly sampled. The range of the y-axis is [1.17, -8], but there few points between 1.17 to -4 and more points between -4 and -8. Hence, using the directly imshow method will plot 1.17 to -4 in less (1/3 in my case) space and -4 to -8 more space (2/3).
As you can see in the below code, the y-ticks are uneven according to data. I want to plot a uniform linear scale on the y-axis as well.
I want some code suggestion here to squeeze/stretch points in the y-axis such that, y-ticks are equidistant.
My code:
## The shape of data is (log tau, arcsec) is (150, 50).
plt.imshow(data, cmap='gray', origin='lower')
plt.xticks([10, 20, 30, 40], [623.5, 623.87, 624.25, 624.63], rotation=45)
plt.yticks([50, 106, 124, 131], [-6, -4, -2, -1]) ## want some code suggestion here to squeeze / stretch points in y-axis such that, y-ticks are equidistant.
plt.gca().set_aspect(1.0 / plt.gca().get_data_ratio(), adjustable='box') ## to make square plot
plt.colorbar()
plt.show()