Plot image on different axes
显示 更早的评论
I am trying to overlay these two figures on top of each other. Since the graphs on the left have specific equations, I am trying to figure out how to change the axes of the image on the right to match the axes of the left figure. I am currently using imagesc for the one on the right, it is a 256 x 256 matrix.

(The image on the right uses 1 to 256 by 256 so how do I change it to -60 to +60 (more or less)?)
1 个评论
dpb
2021-6-18
You'll probably get somebody to 'spearmint if you attach the images for them to play with...
采纳的回答
更多回答(1 个)
DGM
2021-6-19
Consider the example:
inpict = zeros(250);
inpict(50:100,150:200) = 0.6;
x = linspace(-10*pi,10*pi,1000);
y = sin(x)+x;
subplot(1,2,1)
imagesc(inpict); hold on
axis equal; axis tight
subplot(1,2,2)
plot(x,y)
axis equal; axis tight

These can be combined by specifying the axis ranges for imagesc(). In order to get the orientation of the plot and image to match, the axis flipping that imagesc() uses needs to be undone.
inpict = zeros(250);
inpict(50:100,150:200) = 0.6;
x = linspace(-10*pi,10*pi,1000);
y = sin(x)+x;
xaxr = [min(x) max(x)]; % get axis ranges
yaxr = [min(y) max(y)];
imagesc(yaxr,xaxr,flipud(inpict)); hold on % flip image directly
plot(x,y)
set(gca,'ydir','normal') % so that we can undo y axis flip
axis equal; axis tight

类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!