MATLAB Answers

how to set graph size

Asked by Soni huu

Soni huu (view profile)

on 28 Feb 2013
Latest activity Commented on by Ravnalis Michael

Ravnalis Michael (view profile)

on 23 Oct 2019
Accepted Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

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])

Soni huu

Soni huu (view profile)

on 28 Feb 2013
code to set..

Sign in to comment.

1 Answer

Azzi Abdelmalek (view profile)

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 28 Feb 2013
Edited by MathWorks Support Team

MathWorks Support Team (view profile)

on 27 Nov 2018
Accepted Answer

Set the ‘Position’ property on the current figure (gcf). 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])

Dariush Ashtiani

Dariush Ashtiani (view profile)

on 14 Jul 2018
Thank you Azzi for short and to the point answer
ANKIT KUMAR

ANKIT KUMAR (view profile)

on 12 Oct 2018
How can we decide that we are putting position in cms or any other unit ?
Ravnalis Michael

Ravnalis Michael (view profile)

on 23 Oct 2019 at 18:35
I am sorry but it does not work... Do you know an another way?

Sign in to comment.