How do we change the size of a figure (graph) to be larger than the default?

Hi, the size of my screen is 1366x768 (width x height). How can I force the graph below (via command line) to use the entire screen instead of a small figure?
w = 0:pi/100:2*pi;
y1 = sin(w)';
h=plot(w,y1);
I thank you in advance for your help
Emerson

 Accepted Answer

scrsz = get(0,'ScreenSize');
figure('Position',scrsz);
plot(rand(10,1));

5 Comments

Hi Jose Luis, it apparently does what I need, but if I plot something else (see below) it does not work. Do you know what I may be doing wrong with the sequence of the commands?
w = 0:pi/100:2*pi;
y1 = sin(w)';
y2 = sin(w-.25)';
y3 = sin(w-.5)';
startDate = datenum('09-28-2012 09:00:00 AM');
endDate = datenum('09-28-2012 12:20:00 PM');
x = linspace(startDate,endDate,201);
DATAVECTOR=datevec(x);
h=subplot(1,1,1);
plot(x,y1,x,y2,x,y3)
set(h,'XTick',x)
datetick(h,'x','HH','keeplimits')
set(h,'LineWidth',2)
scrsz = get(0,'ScreenSize');
figure('Position',scrsz);
legend(h,'sin(x)','sin(x-0.25)','sin(x-0.50)',1)
set(gca)
set(gca,'FontSize',12, 'FontName','Arial','FontWeight','bold','Color','w','LineWidth',2)
title('TEST','FontSize',26, 'FontName','Arial', 'FontWeight','bold')
xlabel('Hour','FontSize',20, 'FontName','Arial','FontWeight','bold')
ylabel('Value','FontSize',20, 'FontName','Arial','FontWeight','bold')
Thank you a lot in advance for your attention,
Emerson
When you use the command figure a new figure is created. But it seems that you already had one (that you wanted to resize): the figure where you made your plots. You need to set the dimensions of that figure. Try making the figure you want to resize the current figure (click on it), and then:
set(gcf,'Position',scrsz);
Or, let's say you want to do it programatically:
%Create your figure:
fH =figure;
%Do your stuff
plot(rand(10,1));
%resize your figure:
scrsz = get(0,'ScreenSize');
set(fH,'Position',scrsz);
Also, what is the purpose of:
h = subplot(1,1,1);
If you want the axes handle, you can:
lH = plot(rand(10,1));
axesH = ancestor(lH,'axes');
It means, if you run the code above, you will obtain two figures: the first with the curves and a second with the correct size but empty. I wished to have the empty figure with the curves in it.
Thank you
Emerson

Sign in to comment.

More Answers (1)

set(gcf, 'PaperUnits', 'centimeters','PaperPosition', [0 0 15 15])
% you can change paperunits to 'inches' or 'points',...

2 Comments

Hi Azzi, I tried your suggestion and varied the values (0 0 15 15) but it does nothing to the figure (image or graph). Did you tried and worked?
Thank you for your help
Emerson
Ok, because it changed it when you save it to an image file (jpg,...)
José Luis's code is fine

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!