Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As <a href="https://stackoverflow.com/a/7562186/97160">@LewisNorton</a> explained, you need to set the <code>Paper***</code> <a href="https://www.mathworks.com/help/matlab/ref/figure-properties.html" rel="nofollow noreferrer">properties</a> of the figure. Below is an example for producing a PDF file with dimensions <code>420 x 297 mm</code> (A3 size), where the margins between the plot and the file borders are <code>10 mm</code> each (top,bottom,left,right).</p> <pre><code>%# centimeters units X = 42.0; %# A3 paper size Y = 29.7; %# A3 paper size xMargin = 1; %# left/right margins from page borders yMargin = 1; %# bottom/top margins from page borders xSize = X - 2*xMargin; %# figure size on paper (widht &amp; hieght) ySize = Y - 2*yMargin; %# figure size on paper (widht &amp; hieght) %# create figure/axis hFig = figure('Menubar','none'); plot([0 1 nan 0 1], [0 1 nan 1 0]), axis tight set(gca, 'XTickLabel',[], 'YTickLabel',[], ... 'Units','normalized', 'Position',[0 0 1 1]) %# figure size displayed on screen (50% scaled, but same aspect ratio) set(hFig, 'Units','centimeters', 'Position',[0 0 xSize ySize]/2) movegui(hFig, 'center') %# figure size printed on paper set(hFig, 'PaperUnits','centimeters') set(hFig, 'PaperSize',[X Y]) set(hFig, 'PaperPosition',[xMargin yMargin xSize ySize]) set(hFig, 'PaperOrientation','portrait') %# export to PDF and open file print -dpdf -r0 out.pdf winopen out.pdf </code></pre> <p><img src="https://i.stack.imgur.com/Lvlqi.png" alt="screenshot_MATLAB"> <img src="https://i.stack.imgur.com/1pt7G.png" alt="screenshot_PDF"></p> <p>Without a printer at hand, I am using a virtual <a href="http://www.spadixbd.com/freetools/jruler.htm" rel="nofollow noreferrer">screen ruler</a> to check the measurements; Simply display the PDF file with your preferred viewer, and the set the zoom level at 100% (I am using <em><a href="http://en.wikipedia.org/wiki/Sumatra_PDF" rel="nofollow noreferrer">Sumatra PDF</a></em>). If you want to try this yourself, just be aware that some viewers (<em>Adobe Reader</em>) might be using a custom DPI not matching the system default resolution (mine at 96 pixels/inch).</p> <p>Here you can see the bottom and left margins equal to <code>10mm</code>. The same holds for the other two margins:</p> <p><img src="https://i.stack.imgur.com/BUPTX.png" alt="margins_1cm"></p> <p>Note that in the example above, I made the axis cover the entire figure (no gray area in the figure). By default, MATLAB leaves some empty space for tick labels, axis labels, title, etc.. This is of course different from the margins mentioned above, which I assume you already know :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload