How do I print a 1-inch by 1-inch square on a piece of paper?

2 ビュー (過去 30 日間)
Joseph
Joseph 2016 年 2 月 4 日
コメント済み: Walter Roberson 2016 年 2 月 4 日
I have been searching the help files and MATLAB Answers but my pictures are still coming out distorted.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 2 月 4 日
Look at Figure Properties for PaperSize and PaperSizeMode and PaperUnits
Then construct whatever graphics you want on an axes whose Units has been set to 'inch' and with appropriate Position, and with DataAspect set to [1 1 1]; with that combination, a change of 1.0 in your data will correspond to 1.0 inch
  2 件のコメント
Joseph
Joseph 2016 年 2 月 4 日
So I tried:
x=[0,0,1,1,0];
y=[0,1,1,0,0];
plot(x,y)
drawnow
set(gca,'xlimmode','manual','ylimmode','manual')
set(gcf,'units','inches')
set(gcf,'papersize',[8.5,12])%width height
set(gcf,'paperpositionmode','manual');
set(gcf,'paperposition',[2,2,1,1]);%distance from left, distance from bottom, width, height.
daspect([1,1,1]);
axis off
print
print(gcf,'-dpng','-r0','test.png')
winopen('test.png')
The square is about 5/8" x 5/8" when printed and the saved image is showing a buffer around the square, which could be causing the square to be smaller than 1" x 1". How do I remove the buffer?
Walter Roberson
Walter Roberson 2016 年 2 月 4 日
fig = figure('Units', 'inches', 'papersize', [8.5,11], 'paperpositionmode', 'auto');
ax = axes('Units','inches', 'Position', [1 1 1 1])
x=[0,0,1,1,0];
y=[0,1,1,0,0];
plot(ax, x, y)
set(ax, 'visible', 'off', 'dataaspectratio', [1 1 1]);
print(fig)
Tested on my system. Interestingly the square did not show up as 1" x 1" on my display, but printed out as 1" x 1" to within the accuracy of my measuring tape.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCartesian Coordinate System Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by