2

I have made a matrix containing 13 different vectors with ~300K+ rows. I have visualized the matrix by transposing it and using the imagesc function to see the distribution of colors. All vectors have been resampled, processed and normalized between 0 & 1 individually.

The imagesc plot gives me this result (fig 1): Normal imagesc plot

But, when I use the axis functionality to add x & y limits, I get this:

Solid colorbars

How do I maintain the imagesc plot while being able to add custom ticks and labels to the X & y axis? The x axis represents time, while the y axis will get its own labels with sensor names.

Ruchik Yajnik
  • 319
  • 1
  • 4
  • 13

1 Answers1

3

You redefine limits from 0 to 30 on the x-axis while the initial xlimits goes up to 3e5. Same issue with the y-axis

Here's how to redefine the Y-axis to put sensor names:

C = [0 2 4 6 9 ; 8 10 12 44 14; 16 48 10 32 23];
image(C)
% Get axis handle
ax = gca;

% Set where ticks will be
ax.YTick = [1 2 3];
% Set TickLabels;
ax.YTickLabel = {'S1','S2','S3'};

Figure out the ax.YTick where you want the labels to appear.

If you want the x-axis to go from 0 to 30, divide the x component of all vectors by 1e4 before plotting. Alternatively, you can add the line:

ax.XTickLabel = ax.XTick/1e4;
Laure
  • 373
  • 1
  • 9
  • It worked brilliantly. However, I'm a bit confused about the XTick. I created an array ax.XTick [0e5 ... 30e5] did not seem to work. Any suggestions? – Ruchik Yajnik Nov 16 '17 at 14:24
  • 1
    I suggest you first run your code and simply output ax.XTick to see how it looks like, then update the code to define the XTick you want. If you divided your data by 1e4, then ax.XTick = [0e5 30e5] will only show a tick a 0. – Laure Nov 16 '17 at 15:14
  • 1
    I was able to fix it myself just before. Went through the relevant documentation. – Ruchik Yajnik Nov 16 '17 at 15:15