Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getframe is cropping my figure

68 views
Skip to first unread message

Benoît

unread,
Nov 27, 2010, 1:10:05 PM11/27/10
to
Hi!

When I try to use getframe to create a movie, the figure displays correctly, but then the movie command displays two axes from 0 to 1 to the bottom and the left of the window, and as a consequence my actual graphic is cropped (e.g., you can no longer see the title of my graphic in the movie). Please see the code below.

I have two questions that are most probably related:
- How do I make the two axes disappear?
- How do I avoid having my figure cropped?

Thank you very much in advance!

Benoit

--------------------------------------------
maturity = 1/12:1/12:20;
hor = 0:1/12:30;

winsize = [0 0 640 480];
numframes = numel(hor);

fig1 = figure('Position',winsize);
Video = moviein(numframes,fig1,winsize);
set(fig1,'NextPlot','replace');

grex = [1 2 3; 4 5 6; 7 8 9];

for k=1:numel(hor)
hold on
grex2 = grex + k*0.01;
fig1 = area(grex2,0);
xlabel('Maturity');
ylabel('Interest Rate');
year = floor(hor(k));
month = round((hor(k)-year)*12);
title(sprintf('Yield curve -- Year %d , Month %d',year,month));
Video(:,k) = getframe(gcf,winsize);
clf('reset');
hold off
end

movie(Video,3,12)
--------------------------------------------

Benoît

unread,
Nov 27, 2010, 1:20:04 PM11/27/10
to
Hi!

(I just posted this a few minutes ago, but I cannot find the post anywhere. Sorry for any possible duplication, I will close the first post if I realize both were successfully posted)

Please see my code below. I want to create a movie using getframe, but the result shows two axes from 0 to 1 to the left and the bottom of the window, and the figure is cropped (e.g. you cannot see the title of the graphic in the movie).

I have two questions that are most probably related:

- How do I get rid of the two [0 1] axes?


- How do I avoid having my figure cropped?

Thank you very much in advance!

Benoit

-----------------------------------

maturity = 1/12:1/12:20;

Jan Simon

unread,
Nov 28, 2010, 9:22:03 AM11/28/10
to
Dear Benoît,

> (I just posted this a few minutes ago, but I cannot find the post anywhere. Sorry for any possible duplication, I will close the first post if I realize both were successfully posted)

This is a newsgroup.
1. It will take a whil until your posts appear. I've seen times between 1 and 15 minutes.
2. You cannot close a post.



> - How do I get rid of the two [0 1] axes?

Use the debugger to go line by line through your code to find out, where the AXES are created. Then modify this line.

> Video = moviein(numframes,fig1,winsize);
See "help moviein": No longer needed since Matlab 5.3. So I assume your code is older?!

> set(fig1,'NextPlot','replace');

Why replacing? It is more efficient to create one AXES object with "NextPlot" set to "add", and then update the objects in this AXES afterwards. Then there is no need to set the XLABEL etc again and again.

Good luck, Jan

ImageAnalyst

unread,
Nov 28, 2010, 9:34:56 AM11/28/10
to
On Nov 27, 1:20 pm, "Benoît " <benoit_pas...@yahoo.com> wrote:
> Hi!
>
> (I just posted this a few minutes ago, but I cannot find the post anywhere. Sorry for any possible duplication, I will close the first post if I realize both were successfully posted)
>
-----------------------------------------------------------
That's one of the bad points about the Mathworks newsreader, and
probably why we have so many duplicate posts. You'd think they'd be
able to post it immediately if they did the posting, but apparently
not. If you want virtually instant posting, use Google. When i post
from Google it appears within about 5 seconds. With the Mathworks, it
can take several minutes. You will always see posts on Google before
the Mathworks, even for posts originated on the Mathworks web
site,surprisingly. And of course Google has that nice feature where
you can click the star to help you see/track/highlight the
conversations in which you've personally participated.
ImageAnalyst

Benoît

unread,
Nov 28, 2010, 9:59:04 PM11/28/10
to
Jan,

Thanks for your reply. Unfortunately, your post does not solve my problem:
- The two [0 1] axes are not created in my code. When I go through the loop that creates successive frames, I never see these [0 1] appear... and then when I run the "movie" function, all of a sudden these axes appear... my interpretation is that there is a parameter in the "movie" function that I use incorrectly, but I cannot seem to find which one.
- moviein is not needed ==> I had found pieces of code on the web, apparently they were quite old. Thanks for spotting this!
- No 'replace' ==> my intent was to get rid of previous graphics rather than printing new lines over old ones. I thought this is what "set(fig1,'NextPlot','replace')" did, but apparently I am wrong?

Thank you very much for your help,

Benoit

"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <ictoib$k33$1...@fred.mathworks.com>...

0 new messages