Plotting two images on top of each other using imagesc

46 views (last 30 days)
Hey all, I'm using imagesc to present two pictures. One is a jpg that I want stretched and located in a specific place, like this: imagesc([17.04833333 27.07266667], [12.52666667 16.353], a); when a is a pre-loaded jpg file. The other is a matrix of numbers. I want to plot them on top of each other but 'hold on' doesn't seem to work. Any advice? Also about transparency which I will need to use.
Thank you very much!

Answers (1)

Walter Roberson
Walter Roberson on 1 Jun 2015
The form you used works fine with a "hold on", if the purpose is to completely overlay the bottom with the newer one.
Perhaps what you are missing is passing an AlphaData parameter:
imagesc([17.04833333 27.07266667], [12.52666667 16.353], a);
hold on
imagesc(b, 'AlphaData', 0.5)
you can also specify an array of Alphadata the same size as the matrix being imaged.
  2 Comments
Yael V
Yael V on 2 Jun 2015
It doesn't work with 'hold on' , maybe because the jpg and matrix are not the same size, but it's essential that the sizes remain as they are now.
Walter Roberson
Walter Roberson on 2 Jun 2015
I tested in R2014a; the coordinate system established by the first imagesc() persisted with "hold on". When there were no other objects in the axes, the default xlim and ylim are set by the boundaries of the first imagesc(), and "hold on" freezes those coordinates, so the later imagesc() with no coordinates will be partly out of view. You can xlim and ylim if you want to change that.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!