save image with better resolution
2 次查看(过去 30 天)
显示 更早的评论
Hello ... trying to save a plot with screen resolution or better
The saveas works but the resolution is not so good like the original plot The print gives me an error ...
Thanks in advance for any help
matlab code
if flag_ppt
bb=gca;
filedir11=strcat(PlotDir,'Plot1.png') ;
saveas(bb, filedir11,'png');
print(bb,filedir11, '-dpng','-r0')
end
Error messages:
Error using checkArgsForHandleToPrint
MATLAB Graphics handle must be a figure.
Error in checkArgsForHandleToPrint
Error in print>LocalCreatePrintJob (line 326)
handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 150)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});
Error in Read_Noise_Src_ENR_fct_revB (line 234)
print(bb,filedir11, '-dpng','-r0')
Error in MAIN_EDM_Noise_gui (line 224)
Read_Noise_Src_ENR_fct_revB(flag_plot,scrsz, flag_ppt, ...
Error in AE_Gue_revA>CmpParam_Callback (line 398)
MAIN_EDM_Noise_gui
Error in gui_mainfcn (line 95)
feval(varargin{:});
0 个评论
回答(2 个)
Walter Roberson
2017-6-29
print() does not work on axes, only on figures. If you have an axes to output and the rest of the figure should not be output, then create a second figure, copyobj() the axes to it, print the temporary figure, and then delete it.
We suggest you look at the export_fig File Exchange contribution.
0 个评论
Michael Dombrowski
2017-6-29
编辑:Michael Dombrowski
2017-6-29
You have an error with your code which is that print() takes a figure handle, not axes handle. See the print documentation here.
If you want a higher resolution, try using -r800 for 800 DPI.
if flag_ppt
bb=gcf;
filedir11=strcat(PlotDir,'Plot1.png');
print(bb, filedir11, '-dpng','-r800')
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!