Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How do I freeze the axes?

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 04:27:04

Message: 1 of 11

How can I fix the axes so they don't change? I keep setting it, and then every time I add something, it resets. I can't find the answer in the doc set or online.

    cells=zeros(dim);
    cells(seed(1),seed(2))=64;
    image(cells);
    axis equal; axis tight;

    walkers=zeros(num,2);
    walkers(:,1)=randi(dim(1),num,1);
    walkers(:,2)=randi(dim(2),num,1);
    for ii=1:num
        cells(walkers(ii,1),walkers(ii,2))=40;
    end
    image(cells);
    axis equal; axis tight;

See how I have to set the axis every time?
Thanks,

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 04:37:02

Message: 2 of 11

"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message <ho1iqo$s5m$1@fred.mathworks.com>...
> How can I fix the axes so they don't change? I keep setting it, and then every time I add something, it resets. I can't find the answer in the doc set or online.
>
> cells=zeros(dim);
> cells(seed(1),seed(2))=64;
> image(cells);
> axis equal; axis tight;
>
> walkers=zeros(num,2);
> walkers(:,1)=randi(dim(1),num,1);
> walkers(:,2)=randi(dim(2),num,1);
> for ii=1:num
> cells(walkers(ii,1),walkers(ii,2))=40;
> end
> image(cells);
> axis equal; axis tight;
>
> See how I have to set the axis every time?
> Thanks,

I can use hold on, but that uses up too much memory.

Subject: How do I freeze the axes?

From: Steven Lord

Date: 20 Mar, 2010 05:02:47

Message: 3 of 11


"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message
news:ho1iqo$s5m$1@fred.mathworks.com...
> How can I fix the axes so they don't change? I keep setting it, and then
> every time I add something, it resets. I can't find the answer in the doc
> set or online.

Change the XLimMode, YLimMode, and/or ZLimMode properties of your axes.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#XLimMode

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 07:59:05

Message: 4 of 11

"Steven Lord" <slord@mathworks.com> wrote in message <ho1ktf$s5t$1@fred.mathworks.com>...
>
> "Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message
> news:ho1iqo$s5m$1@fred.mathworks.com...
> > How can I fix the axes so they don't change? I keep setting it, and then
> > every time I add something, it resets. I can't find the answer in the doc
> > set or online.
>
> Change the XLimMode, YLimMode, and/or ZLimMode properties of your axes.
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#XLimMode
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>

I wasn't searching on the right terms.
Thanks.

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 16:46:05

Message: 5 of 11

"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message <ho1v89$r7r$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <ho1ktf$s5t$1@fred.mathworks.com>...
> >
> > "Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message
> > news:ho1iqo$s5m$1@fred.mathworks.com...
> > > How can I fix the axes so they don't change? I keep setting it, and then
> > > every time I add something, it resets. I can't find the answer in the doc
> > > set or online.
> >
> > Change the XLimMode, YLimMode, and/or ZLimMode properties of your axes.
> >
> > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#XLimMode
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> >
>
> I wasn't searching on the right terms.
> Thanks.

Oops, I spoke too soon. Sorry about that.

Setting the LimModes is not stopping the axes from being resized when I issue a new image command. The LimModes only have prevent the axes from being changed if you turn 'hold on'. But I can't do that, since it uses way too much memory and slows down my program to a crawl.

Here's the basics of my program (I'm trying to imitate diffusion limited aggregation):

seed=[randi(dim(1)) randi(dim(2))];
cells=zeros(dim);
cells(seed(1),seed(2))=stable;
image(cells); % Causes the axes to be resized according to the size of 'cells'.
axis equal; axis tight; axis off; axis manual;
drawnow;

-create matrix of 'walker' particles, same size as 'cells'
while stable~=0
   -randomly move 'walkers' around their matrix
   image(cells+walkers); % This line resizes and reshows the axes again, even though 'axis ma
end

I need this for my homework and it's killing me. OTOH, I'm probably getting an A in this class anyway.

Thanks for any help,

Subject: How do I freeze the axes?

From: Rune Allnor

Date: 20 Mar, 2010 17:07:29

Message: 6 of 11

On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
wrote:
> "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net> wrote in message <ho1v89$r7...@fred.mathworks.com>...
> > "Steven Lord" <sl...@mathworks.com> wrote in message <ho1ktf$s5...@fred.mathworks.com>...
>
> > > "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net> wrote in message
> > >news:ho1iqo$s5m$1@fred.mathworks.com...
> > > > How can I fix the axes so they don't change? I keep setting it, and then
> > > > every time I add something, it resets. I can't find the answer in the doc
> > > > set or online.
>
> > > Change the XLimMode, YLimMode, and/or ZLimMode properties of your axes.
>
> > >http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props....
>
> > > --
> > > Steve Lord
> > > sl...@mathworks.com
> > > comp.soft-sys.matlab (CSSM) FAQ:http://matlabwiki.mathworks.com/MATLAB_FAQ
>
> > I wasn't searching on the right terms.
> > Thanks.
>
> Oops, I spoke too soon. Sorry about that.
>
> Setting the LimModes is not stopping the axes from being resized when I issue a new image command. The LimModes only have prevent the axes from being changed if you turn 'hold on'. But I can't do that, since it uses way too much memory and slows down my program to a crawl.
>
> Here's the basics of my program (I'm trying to imitate diffusion limited aggregation):
>
> seed=[randi(dim(1)) randi(dim(2))];
> cells=zeros(dim);
> cells(seed(1),seed(2))=stable;
> image(cells);    % Causes the axes to be resized according to the size of 'cells'.
> axis equal; axis tight; axis off; axis manual;
> drawnow;
>
> -create matrix of 'walker' particles, same size as 'cells'
> while stable~=0
>    -randomly move 'walkers' around their matrix
>    image(cells+walkers);  % This line resizes and reshows the axes again, even though 'axis ma
> end

doc axes

After the first call to IMAGE, save the current
axes settings as

ax = axes;

After the subsequent calls, use

axes(ax)

Rune

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 17:44:04

Message: 7 of 11

Rune Allnor <allnor@tele.ntnu.no> wrote in message <6754e674-5e0b-4c25-ac1f-eac1315a1c39@33g2000yqj.googlegroups.com>...
> On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> wrote:
>
> doc axes
>
> After the first call to IMAGE, save the current
> axes settings as
>
> ax = axes;
>
> After the subsequent calls, use
>
> axes(ax)
>
> Rune

Thanks, Rune.
That works. But I still have to reset the axes, using the axes(ax) command. I'm trying to get them to stay fixed, so they don't have to be reset at all (and without using 'hold on').

Subject: How do I freeze the axes?

From: Rune Allnor

Date: 20 Mar, 2010 18:01:08

Message: 8 of 11

On 20 Mar, 18:44, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <6754e674-5e0b-4c25-ac1f-eac1315a1...@33g2000yqj.googlegroups.com>...
> > On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> > wrote:
>
> > doc axes
>
> > After the first call to IMAGE, save the current
> > axes settings as
>
> > ax = axes;
>
> > After the subsequent calls, use
>
> > axes(ax)
>
> > Rune
>
> Thanks, Rune.
> That works. But I still have to reset the axes, using the axes(ax) command. I'm trying to get them to stay fixed, so they don't have to be reset at all (and without using 'hold on').

No, you don't. The only way to have axes *stay* *fixed* is
to use the HOLD ON command. Because in that case you plot
a sequence of figures in the same axis object.

Without the HOLD ON command, what happens is that every time
you plot a new image, you

- Delete the existing image, if any
- Draw the new image
- Matlab automatically computes whatever axis settings
  it thinks appropriate, given the plot

If you want something else then what matlab automatically
does, it is *your* responsibility to adjust the settings.

Rune

Subject: How do I freeze the axes?

From: Jeff

Date: 20 Mar, 2010 18:38:02

Message: 9 of 11

Rune Allnor <allnor@tele.ntnu.no> wrote in message <df0fd14c-ee60-40ae-a196-3f64fd03a226@t23g2000yqt.googlegroups.com>...
> On 20 Mar, 18:44, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> wrote:
> > Rune Allnor <all...@tele.ntnu.no> wrote in message <6754e674-5e0b-4c25-ac1f-eac1315a1...@33g2000yqj.googlegroups.com>...
> > > On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> > > wrote:
> >
> > > doc axes
> >
> > > After the first call to IMAGE, save the current
> > > axes settings as
> >
> > > ax = axes;
> >
> > > After the subsequent calls, use
> >
> > > axes(ax)
> >
> > > Rune
> >
> > Thanks, Rune.
> > That works. But I still have to reset the axes, using the axes(ax) command. I'm trying to get them to stay fixed, so they don't have to be reset at all (and without using 'hold on').
>
> No, you don't. The only way to have axes *stay* *fixed* is
> to use the HOLD ON command. Because in that case you plot
> a sequence of figures in the same axis object.
>
> Without the HOLD ON command, what happens is that every time
> you plot a new image, you
>
> - Delete the existing image, if any
> - Draw the new image
> - Matlab automatically computes whatever axis settings
> it thinks appropriate, given the plot
>
> If you want something else then what matlab automatically
> does, it is *your* responsibility to adjust the settings.
>
> Rune

Oh. I see now.
In that case, I guess I have to use the HOLD ON command and then instead of plotting the entire image again, I have to set and reset individual points.
Thanks for the explanation.

Subject: How do I freeze the axes?

From: Rune Allnor

Date: 20 Mar, 2010 18:48:16

Message: 10 of 11

On 20 Mar, 19:38, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <df0fd14c-ee60-40ae-a196-3f64fd03a...@t23g2000yqt.googlegroups.com>...
> > On 20 Mar, 18:44, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> > wrote:
> > > Rune Allnor <all...@tele.ntnu.no> wrote in message <6754e674-5e0b-4c25-ac1f-eac1315a1...@33g2000yqj.googlegroups.com>...
> > > > On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
> > > > wrote:
>
> > > > doc axes
>
> > > > After the first call to IMAGE, save the current
> > > > axes settings as
>
> > > > ax = axes;
>
> > > > After the subsequent calls, use
>
> > > > axes(ax)
>
> > > > Rune
>
> > > Thanks, Rune.
> > > That works. But I still have to reset the axes, using the axes(ax) command. I'm trying to get them to stay fixed, so they don't have to be reset at all (and without using 'hold on').
>
> > No, you don't. The only way to have axes *stay* *fixed* is
> > to use the HOLD ON command. Because in that case you plot
> > a sequence of figures in the same axis object.
>
> > Without the HOLD ON command, what happens is that every time
> > you plot a new image, you
>
> > - Delete the existing image, if any
> > - Draw the new image
> > - Matlab automatically computes whatever axis settings
> >   it thinks appropriate, given the plot
>
> > If you want something else then what matlab automatically
> > does, it is *your* responsibility to adjust the settings.
>
> > Rune
>
> Oh. I see now.
> In that case, I guess I have to use the HOLD ON command and then instead of plotting the entire image again, I have to set and reset individual points.

Again - no.

You already figured out why that's a bad idea: It takes
a lot of memory. Don't quibble over semantics, but use
the method that works most efficiently: And axes command
like I showed you in th eloop you already have.

Rune

Subject: How do I freeze the axes?

From: Steven Lord

Date: 22 Mar, 2010 00:26:07

Message: 11 of 11


"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message
news:ho31h4$ilv$1@fred.mathworks.com...
> Rune Allnor <allnor@tele.ntnu.no> wrote in message
> <6754e674-5e0b-4c25-ac1f-eac1315a1c39@33g2000yqj.googlegroups.com>...
>> On 20 Mar, 17:46, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
>> wrote:
>>
>> doc axes
>>
>> After the first call to IMAGE, save the current
>> axes settings as
>>
>> ax = axes;
>>
>> After the subsequent calls, use
>>
>> axes(ax)
>>
>> Rune
>
> Thanks, Rune.
> That works. But I still have to reset the axes, using the axes(ax)
> command. I'm trying to get them to stay fixed, so they don't have to be
> reset at all (and without using 'hold on').

Then change the NextPlot property to 'replacechildren'. Look at the
documentation for this property in the Handle Graphics Object Properties
documentation for information about what that property value does.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

No tags are associated with this thread.

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.

Contact us