Thread Subject: Matlab gives negative values to the axis width and height when saving a figure

Subject: Matlab gives negative values to the axis width and height when saving a figure

From: Xavi Alonso

Date: 12 Aug, 2008 15:25:03

Message: 1 of 2

Hello,
I'm trying to get the same axis Position in two different
figures with different axis labels and tick labels. To my
surprise, matlab changes the Position property of the axes
in the figure when saving to an eps or png file (this
happens when I use large font size), sometimes giving
negative values for the axis width and/or height, which then
gives an error when I try to assign them to the Position
property of the axis of another figure.
For example:

fh=figure;
plot.....
....
ca=get(fh,'CurrentAxes');
pos_vect=get(ca,'Position')
saveas(fh,figure_name,'png');
get(ca,'Position')

returns

pos_vect =

    0.2154 0.1435 0.6896 0.7815

ans =

    0.8635 0.7739 -2.3404 -2.0152

I don't have any ResizeFcn defined, and setting
'PaperPositionMode' to 'auto' doesn't help either.
I can use the Position property before saving for assigning
to the axis of another figure, but the result is not as
expected (the axis of the saved figure has actually been
resized by the saveas command).
I guess that my problem could be related to the last
(unanswered) question in this thread

http://www.mathworks.com/matlabcentral/newsreader/view_thread/151519

I'm using Matlab 7.1.0.183 (R14) Service Pack 3
Thank you very much and best regards

Xavi

Subject: Matlab gives negative values to the axis width and height when saving a figure

From: Hui Song

Date: 12 Aug, 2008 17:34:02

Message: 2 of 2

Hi
Try to use hgexport instead.

"Xavi Alonso" <gargle777@hotmail.com> wrote in message
<g7sa0f$g06$1@fred.mathworks.com>...
> Hello,
> I'm trying to get the same axis Position in two different
> figures with different axis labels and tick labels. To my
> surprise, matlab changes the Position property of the axes
> in the figure when saving to an eps or png file (this
> happens when I use large font size), sometimes giving
> negative values for the axis width and/or height, which
then
> gives an error when I try to assign them to the Position
> property of the axis of another figure.
> For example:
>
> fh=figure;
> plot.....
> ....
> ca=get(fh,'CurrentAxes');
> pos_vect=get(ca,'Position')
> saveas(fh,figure_name,'png');
> get(ca,'Position')
>
> returns
>
> pos_vect =
>
> 0.2154 0.1435 0.6896 0.7815
>
> ans =
>
> 0.8635 0.7739 -2.3404 -2.0152
>
> I don't have any ResizeFcn defined, and setting
> 'PaperPositionMode' to 'auto' doesn't help either.
> I can use the Position property before saving for
assigning
> to the axis of another figure, but the result is not as
> expected (the axis of the saved figure has actually been
> resized by the saveas command).
> I guess that my problem could be related to the last
> (unanswered) question in this thread
>
> http://www.mathworks.com/matlabcentral/newsreader/
view_thread/151519
>
> I'm using Matlab 7.1.0.183 (R14) Service Pack 3
> Thank you very much and best regards
>
> Xavi

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
position Xavi Alonso 12 Aug, 2008 11:30:21
saveas Xavi Alonso 12 Aug, 2008 11:30:21
print Xavi Alonso 12 Aug, 2008 11:30:21
rssFeed for this Thread

Contact us at files@mathworks.com