From: redclab on
Hi all,

I have a problem when setting the y-limits for a new figure.
I have made a gui with guide where I have an axes and some other stuff to plot things on that axes. The thing is that the user can interactively change the limits of the axes (that works fine by changing the xlim and ylim), but then there is the possibility to open what is plotted in that axes into a new figure.

What I actually need is a copy of what is plotted in the axes (of the gui) into a new figure. But how can I set the y-limits for the new figure? As the figure doesn't have that property of xlim and ylim.

The x-limits I can set by defining the x as a vector with the limits I want, but the 'y' in my case is an equation so I don't know how I could set that.

Maybe it's just a stupid thing but I can't get it to work!!
Looking forward to your replies!
Thanks a lot in advance,

redclab
From: Walter Roberson on
redclab wrote:

> I have a problem when setting the y-limits for a new figure. I have made
> a gui with guide where I have an axes and some other stuff to plot
> things on that axes. The thing is that the user can interactively change
> the limits of the axes (that works fine by changing the xlim and ylim),
> but then there is the possibility to open what is plotted in that axes
> into a new figure.
>
> What I actually need is a copy of what is plotted in the axes (of the
> gui) into a new figure. But how can I set the y-limits for the new
> figure? As the figure doesn't have that property of xlim and ylim.
> The x-limits I can set by defining the x as a vector with the limits I
> want, but the 'y' in my case is an equation so I don't know how I could
> set that.

get() the XLim and YLim properties from the original containing _axes_
and set() those properties in the new axes.
From: redclab on

> get() the XLim and YLim properties from the original containing _axes_
> and set() those properties in the new axes.

but in which axes if what I have is a new figure?
What I do it is that I write figure() and then I plot the equation, then I don't have any axes like 'axes defined'. I tried to get the CurrentAxes of gcf but it says there are no existing axes.
What I do is:
axes1fig=figure;
figure(axes1fig);
x=logspace(x1min,x1max);
loglog(x,y,...)

but then I don't know how to set the ylimits
I hope I explain myself properly.
Any other suggestion?

Thanks,
redclab
From: Walter Roberson on
redclab wrote:
>
>> get() the XLim and YLim properties from the original containing _axes_
>> and set() those properties in the new axes.
>
> but in which axes if what I have is a new figure?
> What I do it is that I write figure() and then I plot the equation, then
> I don't have any axes like 'axes defined'. I tried to get the
> CurrentAxes of gcf but it says there are no existing axes. What I do is:
> axes1fig=figure;
> figure(axes1fig);

After that,

thisaxes = axes('Parent',axes1fig);

> x=logspace(x1min,x1max);

> loglog(x,y,...)

Add
'Parent' thisaxes
as a parameter to that call


> but then I don't know how to set the ylimits

set(thisaxes, 'YLim', <oldvalue>)
From: Steven Lord on

"redclab " <cintix(a)mixmail.com> wrote in message
news:hv5kck$13k$1(a)fred.mathworks.com...
>
>> get() the XLim and YLim properties from the original containing _axes_
>> and set() those properties in the new axes.
>
> but in which axes if what I have is a new figure?
> What I do it is that I write figure() and then I plot the equation, then I
> don't have any axes like 'axes defined'.

If you don't have an axes in your figure when you attempt to PLOT, one will
be created for you. Lines can't be just "floating" in a figure.

> I tried to get the CurrentAxes of gcf but it says there are no existing
> axes.

That's entirely possible.

> What I do is:
> axes1fig=figure;
> figure(axes1fig);
> x=logspace(x1min,x1max);
> loglog(x,y,...)

LOGLOG will notice that you don't have an axes and will create one for you.

> but then I don't know how to set the ylimits

After your LOGLOG call, YLIM will return information about, or set, the Y
axis limits for the axes created by LOGLOG.

> I hope I explain myself properly.
> Any other suggestion?

If you just want the axes to be copied into a new figure, use COPYOBJ with
the handle of the new figure into which you want the axes to be copied and
the handle of the axes to be copied as inputs.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com