채택된 답변

Image Analyst
Image Analyst 2023년 10월 5일

0 개 추천

Try this, and see attached demos. Adapt as needed.
% Draw a small image inset in the upper right corner of a larger plot.
% Ref: https://www.mathworks.com/matlabcentral/answers/60376-how-to-make-an-inset-of-matlab-figure-inside-the-figure#comment_654093
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
x = linspace(0, 1);
y1 = sin(2*pi*x);
figure(1)
% plot on large axes
plot(x, y1, 'LineWidth', 2)
grid on;
ax1 = gca; % Store handle to axes 1.
% Create smaller axes in top right, and plot on it
% Store handle to axes 2 in ax2.
ax2 = axes('Position',[.6 .6 .3 .3])
ax2 =
Axes with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.6 0.6 0.3 0.3] Units: 'normalized' Use GET to show all properties
box on;
fileName = 'peppers.png';
rgbImage = imread(fileName);
imshow(rgbImage);
axis('on', 'image');
% Now draw something back on axis 1
hold(ax1, 'on'); % Don't blow away existing curve.
y2 = cos(2*pi*x/0.7);
plot(ax1, x, y2, 'r-', 'LineWidth', 2);

댓글 수: 4

Sumit
Sumit 2023년 10월 9일
Thanks, but i want inserted image to be along the curve line......Unable to do that
Image Analyst
Image Analyst 2023년 10월 9일
Why were you unable to? Did you not set up your 'Position' vector properly in the call to axes()???
Sumit
Sumit 2023년 10월 11일
In position vector only i am facing problem. I will figure it out
Thanks
OK. The form is [x, y, width, height] for the lower left corner of the inset image, so you have to figure out what all those values are. If you want to move the axes, then you must delete the old one before setting the new one.
delete(ax2); % Delete old inset image.
% Make new axes in a new place.
ax2 = axes('Position',[xLeft, yBottom, imageWidth, imageHeight]);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

DGM
DGM 2023년 10월 11일

0 개 추천

See also:
A custom image (with transparency) following a plot trace to form an animation:
Using a custom image (with transparency) as a custom plot marker:

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2023년 10월 5일

답변:

DGM
2023년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by