Adding a plot to existing plot.

조회 수: 72 (최근 30일)
Lizan
Lizan 2014년 10월 3일
댓글: BHARATHI 2022년 8월 1일
I have a base plot in which I would like to add a smaller version of a second plot/figure ontop of the base plot at a certain location.
The second plot (or figure) is already saved as a .fig file. How do I import the .fig file and its data and plot it as is but smaller (so it fits inside the base plot without hiding base plot data) onto the base plot?
  댓글 수: 1
BHARATHI
BHARATHI 2022년 8월 1일
Add the title "Sample Mass" to the existing plot

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

채택된 답변

Chad Greene
Chad Greene 2014년 10월 4일
Hi Lizan,
This could be a two-parter. First, load the figure, get its children, then get the x and y data of its children. Second, create a second set of axes and plot. Here is an example of getting children of current axes and plotting the data on a smaller inset axis:
plot(1:5,11:15,'rx','markersize',12);
hold on
plot(1.5:4.5,12:15,'bo','markersize',12);
ch = get(gca,'children');
x1 = get(ch(1),'xdata');
y1 = get(ch(1),'ydata');
x2 = get(ch(2),'xdata');
y2 = get(ch(2),'ydata');
axes('pos',[.6 .2 .25 .25])
plot(x1,y1,'rp-')
hold on
plot(x2,y2,'bs-')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by