필터 지우기
필터 지우기

Save a figure with two plots

조회 수: 1 (최근 30일)
Joseph Cullen
Joseph Cullen 2012년 7월 11일
This seems like it should be very simple, but it doesn't work. I am plotting two lines in a figure, and want to save the figure as an image. However, the handle h is a vector and saveas doesn't like it. I can't find any help with this in the documentation. What am I missing?
h = plot(price,supply,price,demand)
saveas(h,'myplot','png')
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2012년 7월 11일
give us a real exemple
Joseph Cullen
Joseph Cullen 2012년 7월 12일
This is the real example. It is a simple supply and demand plot.

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

채택된 답변

Kevin Claytor
Kevin Claytor 2012년 7월 11일
Your code is just saving the current axes, you want;
hfig = figure;
hplot = plot(price,supply,price,demand)
saveas(hfig,'myplot','png')
  댓글 수: 2
Joseph Cullen
Joseph Cullen 2012년 7월 12일
편집: Joseph Cullen 2012년 7월 12일
Works! Thanks.
so the handles returned by plot are for each plot in the figure. hfig=figure; gives the handle to the whole figure.
Thats what I need to know.
Matt Kindig
Matt Kindig 2012년 7월 12일
To be precise, the handles returned by plot are handles each of the line objects that make up the plot.
h = plot(price, supply, price, demand); %handles to 2 line objects
ha = get(h(1),'parent'); %handle to axes object
hf = get(ha,'parent'); %handle to figure object

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by