Setting desired margins and ratio for plot

65 ビュー (過去 30 日間)
Francesco Giuseppe Fornari
Francesco Giuseppe Fornari 2019 年 8 月 5 日
コメント済み: Adam Danz 2019 年 8 月 8 日
Hi,
I would like to
1) set margins for my plot, which is authomatically shown as follows:
Cattura.JPG
I need white upper margins in order to see the horizontal line connecting the diamonds above.
I have tried with Control axes layout (https://it.mathworks.com/help/matlab/creating_plots/automatic-axes-resize.html ) , with no result
2) I would also like the picture to be shown in normal ratios (I mean, same length for data units along x and y axis).
I have tried with data aspect ratio (https://it.mathworks.com/help/matlab/ref/daspect.html) in order to disable stretch-to-fill behavior by setting
daspect('manual') or daspect([1 1 1]) without succeeding...
I'd really appreciate the help.
thanks in advance!

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 6 日
編集済み: Adam Danz 2019 年 8 月 8 日
"axis equal" will set the aspect ratio equal between both axes.
"xlim" and "ylim" will set the axis limits which you can use to add margins.
axis equal % to set equal aspect ratio
ylim([-5,40]) % to add space above and below your data
xlim([-10,110]) % to add space to the left and right of your data
If you have the handle to you axis, it's best to specify the handle,
axh = gca(); % Get handle to axis
axis(axh,'equal')
ylim(axh,[-5,40])
xlim(axh,[-10,110])
  2 件のコメント
Francesco Giuseppe Fornari
Francesco Giuseppe Fornari 2019 年 8 月 8 日
great, I needed to handle the axis,
thanks!
Adam Danz
Adam Danz 2019 年 8 月 8 日
I recommend always using handles when possible.
Glad I could help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by