saving an subplotted image

I have an image
subplot(1,2,1) subplot(1,2,2)
two images in one figure window,now i want to write this image,i posted this question ,but could not get relevant answer ,please help

답변 (3개)

Iñigo Moreno
Iñigo Moreno 2020년 9월 28일

1 개 추천

With the newer versions of matlab, if you just want to save one of the subplots to a file:
h=subplot(2,1,1);
plot(1:10);
myAxes=findobj(h,'Type','Axes');
exportgraphics(myAxes,'myFile.pdf');
Grzegorz Knor
Grzegorz Knor 2011년 12월 8일

0 개 추천

Do you want save it as one image or two separately images?
If one: use print
If two: copy each plot to new figure ( copyobj ) and then print.
Daniel Shub
Daniel Shub 2011년 12월 8일

0 개 추천

or do something like
figure;
subplot(2,2,1);
plot(1:10);
hax = subplot(2,2,2);
plot(1:5);
Make a new figure, copy the axis to it, scale the axis to be the "full" size, and print it.
hfig = figure;
hax_new = copyobj(hax, hfig);
set(hax_new, 'Position', get(0, 'DefaultAxesPosition'));
print(hfig);
If you want a jpg, od:
print(gcf, '-djpeg', 'myfigure')

댓글 수: 5

Image Analyst
Image Analyst 2011년 12월 8일
Yes, in fact "saving figures" questions are asked once or twice a day. Probably the most frequently asked question there is.
Pat
Pat 2011년 12월 8일
Daniel thanks for your code,but it is not suiting my application,it is stored as pdf format,i want to store in jpg,i have created a folder named 'newimages' ,i want it to save in that specified location,because i am going to perform some operation on that,by recalling images in that folder,please help
Sean de Wolski
Sean de Wolski 2011년 12월 8일
Pat, please read the documentation Grzegorz and I have both pointed you to for print(). It will tell you how to print to a jpg.
Daniel Shub
Daniel Shub 2011년 12월 8일
If you want a jpg (you should edit your question to include this information) just add the jpg flag ... (see my edited answer).
Pat
Pat 2011년 12월 9일
Thanks Daniel

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

제품

태그

질문:

Pat
2011년 12월 8일

답변:

2020년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by