save image with better resolution

1 次查看(过去 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{:});

回答(2 个)

Walter Roberson
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.

Michael Dombrowski
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

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by