1

consider the following code

x = [-1:0.1:1];
subplot(2,2,1)
imagesc(x,x,abs(x)/100)
colorbar
subplot(2,2,2)
imagesc(x,x,abs(x))
colorbar

Code Result

What I want to happen Is that both images will be on the same color scale, and the same color bar I.e., that the left will be mostly blue, while the right one will show the full scale.

AJ_Nur
  • 136
  • 15
Amir Sagiv
  • 376
  • 5
  • 23
  • What is the left plot supposed to show to thre reader? It's going to be all blue. (Composing answer, just wondering) – Ian Riley Oct 10 '16 at 03:09
  • (Assuming this was just an example you chose, and your real case has more varied data) – Ian Riley Oct 10 '16 at 03:21
  • 1
    @IanRiley, in my use case, I actually want to show the reader that the left plot has less variability then the right one. So having it more homogeneous blue would be the desired result – Amir Sagiv Oct 10 '16 at 03:51
  • Ah! That use case makes a lot more sense. (Fixed a typo in my answer). – Ian Riley Oct 10 '16 at 04:10

1 Answers1

1

EDIT: Made the range fit both.

x = [-1:0.1:1];

subplot(1,2,2)
imagesc(x,x,abs(x))
colorbar
c2 = caxis;

subplot(1,2,1)
imagesc(x,x,abs(x)/100)
colorbar
c1 = caxis;
c3 = [min([c1 c2]), max([c1 c2])];
caxis(c3)

subplot(1,2,2)
colorbar off
Ian Riley
  • 523
  • 2
  • 8
  • Works brilliantly, thank you. One should note that this imposes the second colorscale on the first, and not just equates them, which is what I needed. I wonder if there's a way to create a colorbar for both. If, for example, `subplot(2,2,1)` was `imagesc(x,x,-x)`, for example. – Amir Sagiv Oct 10 '16 at 04:29
  • 1
    This edited version takes the union of both colorbars- hows that? – Ian Riley Oct 10 '16 at 04:54