How can I export figure as png?

조회 수: 307 (최근 30일)
Tomas
Tomas 2014년 10월 7일
댓글: Image Analyst 2023년 10월 22일
I have the script which creates 3D figure. The only way to save it is
hgsave(graph, [input, output, '\', string{i + 8}, '.png'],'-v7.3');
I tried different ways to save it as png and all failed. It stores only axis.
print(graph,'-dpng',[input,output,'\',string{i +8},'.png']);
saveas(graph, [input, output, '\', string{i + 8}], 'png');
hgexport(graph, [input, output, '\', string{i + 8}, '.png'], hgexport('factorystyle'), 'Format', 'png');

채택된 답변

Wouter
Wouter 2014년 10월 7일
Best option is to use the export_fig function from the file exchange. It actually works out of the box and intuitively (not like the annoying builtin saveas function)
  댓글 수: 2
Shaukat
Shaukat 2023년 10월 22일
i have some issues to save figure .it shows some errors as below
I have some problem in my installed Matlab. can you send me any proper person link to guide me for this issue. When i am going to save my figures, its show some errors, even i have installed Mapping toolbox.
Below , i attached error shows my Matlab,
Warning: Probably because you do not have Mapping Toolbox, getar was performed by an approximative method.
> In getar (line 24)
In setar_ll (line 14)
In run_inversion_3flt_pso (line 154)
Error using printopt
Too many input arguments.
Error in matlab.graphics.internal.mlprintjob

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

추가 답변 (3개)

Julia
Julia 2014년 10월 7일
편집: Julia 2014년 10월 7일
Hi,
I create a figure and save it with the follwoing command:
saveas(gcf,'picture.png')
Perhaps
saveas(gcf, [input, output, '\', string{i + 8}], 'png');
works.
  댓글 수: 1
Tomas
Tomas 2014년 10월 7일
All I tried didn't work. Even if I select Save as from figure menu it still save only the axis.

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


Image Analyst
Image Analyst 2014년 10월 7일

Michael Haderlein
Michael Haderlein 2014년 10월 7일
편집: Michael Haderlein 2014년 10월 7일
Did you try another renderer? I can't really explain a lot about it, but I think I once had a similar problem (though everything was black in my case) and choosing another renderer has fixed the case.
In case neither this nor the other suggestions work: I feel a bit embarrassed to mention it here, but once I was desperate enough to simply make a screenshot and save this. In case none of the solutions here works, this will for sure.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by