save image with better resolution
    4 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (2)
  Walter Roberson
      
      
 on 29 Jun 2017
        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 Comments
  Michael Dombrowski
      
 on 29 Jun 2017
        
      Edited: Michael Dombrowski
      
 on 29 Jun 2017
  
      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 Comments
See Also
Categories
				Find more on Interactive Control and Callbacks in Help Center and File Exchange
			
	Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

