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

 採用された回答

José-Luis
José-Luis 2012 年 10 月 3 日
scrsz = get(0,'ScreenSize');
figure('Position',scrsz);
plot(rand(10,1));

5 件のコメント

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
José-Luis
José-Luis 2012 年 10 月 3 日
What does "it does not work" mean?
José-Luis
José-Luis 2012 年 10 月 3 日
編集済み: José-Luis 2012 年 10 月 3 日
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');
Emerson De Souza
Emerson De Souza 2012 年 10 月 3 日
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
José-Luis
José-Luis 2012 年 10 月 3 日
See my previous comment.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 3 日
編集済み: Azzi Abdelmalek 2012 年 10 月 3 日
set(gcf, 'PaperUnits', 'centimeters','PaperPosition', [0 0 15 15])
% you can change paperunits to 'inches' or 'points',...

2 件のコメント

Emerson De Souza
Emerson De Souza 2012 年 10 月 3 日
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
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 3 日
編集済み: Azzi Abdelmalek 2012 年 10 月 3 日
Ok, because it changed it when you save it to an image file (jpg,...)
José Luis's code is fine

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

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by