MATLAB Answers

Superimposing two figures on the top of each other

116 views (last 30 days)
Tommy on 14 Dec 2014
Commented: Tommy on 17 Dec 2014
Hi everyone
I have a question regarding on superimposing two figures.
For example, I have two figures which both have different scaling of x-axis and y-axis. Is there a function that can superimpose these two figures.
For example, I have these two figures.
You can see that the x-axes and the y-axes of these two figures are differently scaled. Is it possible that place the first figure on the top the second figure, so that the curly can be seen on the top of the second image. By the way, the second image was created by using imagesc() function.
I tried to use the following code
  1. figure(1)
  2. imagesc()
  3. hold on
  4. plot(x,y)
But it did not work due to the difference in x and y axes.
Please, could someone advise me.
Thank you very much

Accepted Answer

Rick Rosson
Rick Rosson on 14 Dec 2014
m = 1800 / ( 3 - -3) ;
dx = 1800 / 2 ;
u = m*x + dx ;
n = 1000 / ( 1.6 - -1.6 ) ;
dy = 1000 / 2 ;
v = n*y + dy

More Answers (2)

matt dash
matt dash on 15 Dec 2014
Don't use "hold on" to plot both the image and the plot in the same axes. Instead, create two separate axes on top of each other. Draw the image in the first axes (the one on the bottom) and the plot on top:
axes('position',[same thing],'color','none')

Sign in to comment.

Sean de Wolski
Sean de Wolski on 16 Dec 2014
Edited: Sean de Wolski on 16 Dec 2014
It's actually there when you plot. Just in the upper left hand corner because that's where the data are located. This will make it more obvious.
hold on
If you want the line in the middle, then adjust the data to be in the middle like Rick has done.
  1 Comment
Tommy on 17 Dec 2014
Thank you very much for you advice, I got it working with Rick's method.

Sign in to comment.



Community Treasure Hunt

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

Start Hunting!