saving an subplotted image

162 Ansichten (letzte 30 Tage)
Pat
Pat am 8 Dez. 2011
Beantwortet: Iñigo Moreno am 28 Sep. 2020
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

Antworten (3)

Iñigo Moreno
Iñigo Moreno am 28 Sep. 2020
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 am 8 Dez. 2011
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 am 8 Dez. 2011
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 Kommentare
Daniel Shub
Daniel Shub am 8 Dez. 2011
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 am 9 Dez. 2011
Thanks Daniel

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by