Change figure size without changing plot size

50 views (last 30 days)
Hello,
How can i change the size of a figure without changing the inside plot?
I want to create a large figure window with a small plot at a specific position (to make room for a slider for exmple)
Thanks
  1 Comment
Adam
Adam on 7 Sep 2022
Edited: Adam on 7 Sep 2022
If you mean you want to change the size of an existing figure without changing the size of a plot that is a little more complicated (but still involves the same idea as below, explicitly setting the axes properties).
But if you just want to create one then create the figure of whatever size you want, using the 'Position' property in the call to figure. Then do the same with the axes function, also using 'Position' (and also 'Parent') e.g.
hFig = figure( 'Position',... )
hAxes = axes( hFig, 'Position',... )
Depending if you want the axes to be fixed size or relative to the figure you can also change the 'Units' property of the axes between e.g. 'pixels' and 'normalized'

Sign in to comment.

Answers (1)

vamshi sai yele
vamshi sai yele on 14 Sep 2022
Hi Tal,
As per my understanding you want to change the size of the figure without changing the inside plot.
I have tried to reproduce it from my end the solution attached bellow
x5=0:0.1:10;
x1 = x5*2
y1 = cos(x5)
x2 = x5*3
y2 = sin(x5)
a= figure;
b= axes(a,"Units","pixels","Position",[30 30 200 200])
plot(x5,y1)
Here, in this code, the dimensions of the inner plot is mentioned in [left bottom width height] fashion.
For better understanding, kindly refer to this link. Hope, you find it helpful.

Community Treasure Hunt

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

Start Hunting!