How to create a plot with constant figure size and inner position

134 ビュー (過去 30 日間)
Jesper Bjerregaard
Jesper Bjerregaard 2021 年 3 月 5 日
コメント済み: Ken Naumann 2023 年 5 月 4 日
Hi,
Is it possible to generate a plot, where one is in control of the figure size, and the location of the inner position of the plot and of the figure? Ideally I'd like to control the TightInset parameter, but since that is "read-only", it doesn't seem like an option.
I'm trying to create a plot for a data-sheet, where the sizes of the figure as well of the axes and its position are always the same. Everything should always be in the same postion independently of being active on the plot or not. Generally I'd like the plot to always have the same size and location independant of if I'm using two y-axis, with or without labels, titles, font sizes, etc.
I've dabbled with the different parameters from
and
but there doesn't seem to be an obvious way of doing this.
Regards
  1 件のコメント
Ken Naumann
Ken Naumann 2023 年 5 月 4 日
Issue I encountered was:
set innerposition values of ax, ax1,ax2, to same value ... (to align y-axis of UI figures) on a figure.
set PositionConstraint='innerposition' on ax,ax1, and ax2
figure looks good , all aligned
savefig the fig
openfig the fig --- ax1 innerposition got changed
and ax,ax1,ax2 Position.constraint changed to outerposition.
Any idea how to keep innerposition alignment?

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

採用された回答

Aghamarsh Varanasi
Aghamarsh Varanasi 2021 年 3 月 8 日
Hi
You can create plots with a fixed position and a fixed size by setting the 'position' property. By default, 'position' is in pixels.
x0=50;
y0=50;
width=500;
height=400;
set(gcf,'position',[x0,y0,width,height])
You can specify other units (inches, centimeters, normalized, points, or characters). For example:
set(gcf,'units','points','position',[x0,y0,width,height])
  3 件のコメント
Gonzalo Villegas Curulla
Gonzalo Villegas Curulla 2023 年 1 月 9 日
Thanks for your code, @Jesper Bjerregaard! It worked wonderfully for me. I was getting upset with the OuterPosition, Position, and InnerPosition of several figure and axes handles. In fact, I do not comprehend the difference between Position and InnerPosition. Does anyone know? The documentation does not make it clear.
Jesper Bjerregaard
Jesper Bjerregaard 2023 年 1 月 9 日
編集済み: Jesper Bjerregaard 2023 年 1 月 9 日
No problem.
They seem to be the same.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by