How can I add x and y ticks to my imagesc graph?
44 views (last 30 days)
I have the graph with the x and y data given in the files attached. These values vary in order of magnitude from 10^1 to 10^5, and 10^0 to 10^4 respectively. I have used centered ticks for imagesc graphs below, but for some reason with this data it just does not want to do it. The variable n for imagesc is also attached.
ax = gca;
ax.XTick = x;
ax.YTick = y;
ax.YDir = 'normal';
What I get is this:
Clearly, it does not even put all the ticks and the ticks are not even correct. The data x and y varies between said magnitude and each succesive element in their vectors jump by an order of magnitude less than the previous value, for example: 1e-1 2e-1 ... 9e-1 1e1 2e1 3e1 and so on. I've tried using pcolor instead to no avail.
Dave B on 23 Nov 2021
Edited: Dave B on 23 Nov 2021
When you use image (or imagesc), the values in the matrix are distributed evenly. Changing the ticks just changes what's labels.
It sounds to me like pcolor is what you want. But you need to specify the x and y values when calling pcolor (and if you like, also) when specifying the ticks. Finally, you might consider a log scale for these data.
I've created all four combinations below (I set color limits just to make it easier to see)
note that you can do 'shading flat' if you want to avoid all the lines: