how to set my graphic size to (w:h=550:400) now my graph size is 560:420 (automatic) [ day_number, daily_rain ] = DailyRain( RainData, 2010, 1); andemande = plot( day_number, daily_rain,'-ok' ); set(andemande,'LineWidth',1); day_numbermax = max(day_number); day_numbermin = min(day_number); datetick('x','dd-mmm','keepticks') grid on; ylabel('Akumulasi Curah Hujan (mm)') xlabel('Hari') xlim([day_numbermin day_numbermax])

1 件のコメント

Soni huu
Soni huu 2013 年 2 月 28 日
code to set..

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

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2024 年 11 月 13 日
編集済み: MathWorks Support Team 2024 年 11 月 13 日

44 投票

Set the ‘Position’ property on the current figure (gcf). Specify the position as a vector of the form “[x0 y0 width height]”, where “x0” and “y0” define the distance from the lower-left corner of the screen to the lower-left corner of the figure. By default, the position is in pixels. x0=10; y0=10; width=550; 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]) You can also save a handle to your figure and set the Position property using dot notation: f = figure; f.Position = [10 10 550 400];

7 件のコメント

abory kikla
abory kikla 2016 年 3 月 13 日
ممكن مساعدة
Govind Narayan Sahu
Govind Narayan Sahu 2017 年 12 月 16 日
thanks
Dariush Ashtiani
Dariush Ashtiani 2018 年 7 月 14 日
Thank you Azzi for short and to the point answer
ANKIT KUMAR
ANKIT KUMAR 2018 年 10 月 12 日
How can we decide that we are putting position in cms or any other unit ?
Ivan Mich
Ivan Mich 2019 年 10 月 23 日
I am sorry but it does not work... Do you know an another way?
Giuseppe
Giuseppe 2021 年 3 月 25 日
Hi @Azzi Abdelmalek, if I want to change only "width" and "height", what are the default values of x0 and y0?
Oséias Farias
Oséias Farias 2021 年 7 月 4 日
Thanks!

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

その他の回答 (1 件)

Amirhossein Sadeghi Manesh
Amirhossein Sadeghi Manesh 2021 年 7 月 22 日
編集済み: Amirhossein Sadeghi Manesh 2021 年 7 月 22 日

10 投票

Resizing the figure is mentioned at Matlab's documentation.
doc figure
Scroll down to the Change Figure Size section.
If you hadn't assigned a name for your figure, then use gcf (cf in gcf stands for current figure).
fig=gcf;
fig.Position(3:4)=[550,400];
And put these two lines before your plot of interest.
If your aim is to just change the width and height of your figure as your question sounds like that, then you don't need to change the first and second entries of position. The first two entries are about the position of the figure window in your screen which you can drag and drop that window and has no effect on the size of the figure (and thus no effect on what you put into your paper/book ^_^).

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by