print figure with prescript axes position
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Sri Adiyanti
 am 17 Jul. 2021
  
    
    
    
    
    Bearbeitet: Richard Quist
    
 am 28 Nov. 2021
            Hi there,
I printed a figure with a black background and axes handle, but can't seem to reduce the margin when saving it using "print" comment. 
Please see below example of the code - dimensions is correct, but when i defined axes position as [0 0 1 1] it still leaves some margins on the background (see attached figure).
Any suggestion? 
 figure;
   def.dimensions = [6 6]; % Width & Height in cm
   set(gcf, 'PaperPositionMode', 'manual');
   set(gcf, 'PaperUnits', 'centimeters','PaperOrientation','Portrait');
   xSize = def.dimensions(1);    ySize = def.dimensions(2);    set(gcf,'paperposition',[0 0 xSize ySize])  
   ax = axes('Position',[0 0 1 1],'Box','off');
   colID = randsample(nCols,1);
   plot(x,y,'LineStyle','-','LineWidth', 0.1,'Color', BrightCol.Code(colID));  
    axis equal;
    ax.XAxis.Color = 'none';     ax.YAxis.Color = 'none';        set(ax,'XColor', 'none','YColor','none');       set(ax,'Visible','off'); 
    set(gcf,'color',[0.1 0.1 0.1])   
   set(gcf, 'InvertHardCopy', 'off');
   outdir = [ outputDir,char(nameGroups(i)),'\'];    
    filename = [outdir,[fileID,'.jpeg']];    
    print(gcf, filename, '-djpeg', '-r1200');
1 Kommentar
  Scott MacKenzie
      
 am 17 Jul. 2021
				It would help if you provided code that can be executed.  As is, your code crashes because it accesses unitialized variables.
Akzeptierte Antwort
  Richard Quist
    
 am 28 Nov. 2021
        
      Bearbeitet: Richard Quist
    
 am 28 Nov. 2021
  
      % in R2020a or later - create file in current directory:
exportgraphics(gcf, 'output.jpg', 'Resolution', 1200); 
exportgraphics will eliminate most of the "margins" typically included when using the print command
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


