<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Hold Everything!</title>
	<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Mon, 23 Nov 2009 00:15:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Linus Atorf</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30502</link>
		<dc:creator>Linus Atorf</dc:creator>
		<pubDate>Thu, 30 Jul 2009 20:50:04 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30502</guid>
		<description>The "hold all" command is one of the most useful when plotting data. In fact, in my first year using MATLAB I only knew about "hold on" and "hold off" (as apparently many here), and was a bit annoyed at times. How relieved was I when some day I learned this "hold all" trick.

Together with the pratice to save handles from plots and include them in the legend-command, "hold all" is one of the very first things I teach MATLAB newbies (if I get the chance).</description>
		<content:encoded><![CDATA[<p>The &#8220;hold all&#8221; command is one of the most useful when plotting data. In fact, in my first year using MATLAB I only knew about &#8220;hold on&#8221; and &#8220;hold off&#8221; (as apparently many here), and was a bit annoyed at times. How relieved was I when some day I learned this &#8220;hold all&#8221; trick.</p>
<p>Together with the pratice to save handles from plots and include them in the legend-command, &#8220;hold all&#8221; is one of the very first things I teach MATLAB newbies (if I get the chance).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iain</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30423</link>
		<dc:creator>Iain</dc:creator>
		<pubDate>Tue, 30 Jun 2009 16:05:48 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30423</guid>
		<description>I just had a hold-related problem and remembered this blog post. As Urs commented saving the hold state isn't simple. ishold doesn't seem to distinguish between "hold on" and "hold all" so I had to grab gcf properties with get.

Saving the hold state and reinstating is polite in utility plotting functions. I second the thought that being able to do something like the following would be nice built in behavior:

&lt;code&gt;% Save state
old_hold = hold;
...
% do stuff including hold on/off/all commands
...
% Reinstate state
hold(old_hold);&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I just had a hold-related problem and remembered this blog post. As Urs commented saving the hold state isn&#8217;t simple. ishold doesn&#8217;t seem to distinguish between &#8220;hold on&#8221; and &#8220;hold all&#8221; so I had to grab gcf properties with get.</p>
<p>Saving the hold state and reinstating is polite in utility plotting functions. I second the thought that being able to do something like the following would be nice built in behavior:</p>
<p><code>% Save state<br />
old_hold = hold;<br />
&#8230;<br />
% do stuff including hold on/off/all commands<br />
&#8230;<br />
% Reinstate state<br />
hold(old_hold);</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amir</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30372</link>
		<dc:creator>Amir</dc:creator>
		<pubDate>Mon, 08 Jun 2009 21:14:12 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30372</guid>
		<description>Yes! It definitely helps. Thanks for sharing the information.</description>
		<content:encoded><![CDATA[<p>Yes! It definitely helps. Thanks for sharing the information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30368</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Mon, 08 Jun 2009 03:15:15 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30368</guid>
		<description>I've recently been plotting several quantities on the same axes that have required the use of hold.  I appreciate the tip and will try it in the future.

One approach that I've been trying recently is building my arguments in a cell array as I'm assembling what I what plotted rather than call subsequent plot/line, etc.  I doesn't make any sense really for a single plot, but I found myself reusing the plot variables many times, like when I have a series of baselines to compare against, and putting them in a cell array made for a nice compact way to plot the same quantities again.

&lt;pre&gt;
curvs_baseline=[{x1} {y1} {'r-'}];
...
cv=[curvs_baseline {xn} {yn} {'g-'}];
hc=plot(cv{:})
&lt;/pre&gt;

All in all, I've been finding lots of new uses for cell arrays, that I'm still discovering after 10+ years programming in MATLAB.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve recently been plotting several quantities on the same axes that have required the use of hold.  I appreciate the tip and will try it in the future.</p>
<p>One approach that I&#8217;ve been trying recently is building my arguments in a cell array as I&#8217;m assembling what I what plotted rather than call subsequent plot/line, etc.  I doesn&#8217;t make any sense really for a single plot, but I found myself reusing the plot variables many times, like when I have a series of baselines to compare against, and putting them in a cell array made for a nice compact way to plot the same quantities again.</p>
<pre>
curvs_baseline=[{x1} {y1} {'r-'}];
...
cv=[curvs_baseline {xn} {yn} {'g-'}];
hc=plot(cv{:})
</pre>
<p>All in all, I&#8217;ve been finding lots of new uses for cell arrays, that I&#8217;m still discovering after 10+ years programming in MATLAB.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30365</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 04 Jun 2009 14:43:54 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30365</guid>
		<description>Folks-

My bad.  I forgot to insert &lt;tt&gt;hold off&lt;/tt&gt; between my plots so old lines were being held onto and plotted on top of new ones.  &lt;tt&gt;legend&lt;/tt&gt; seems fine.  I updated the post to insert the commands and recreate the graphs.

--Loren</description>
		<content:encoded><![CDATA[<p>Folks-</p>
<p>My bad.  I forgot to insert <tt>hold off</tt> between my plots so old lines were being held onto and plotted on top of new ones.  <tt>legend</tt> seems fine.  I updated the post to insert the commands and recreate the graphs.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pekka Kumpulainen</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30364</link>
		<dc:creator>Pekka Kumpulainen</dc:creator>
		<pubDate>Thu, 04 Jun 2009 13:23:13 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30364</guid>
		<description>The colors of the lines in the legend of the last example are correct in 2008b and 2009a. Something else must have happened in the example here.
The line styles and colors seem to get updated automatically in the legend if changed. 
FaceAplha of patch objects is not updated in legend though

Anyway, nice to know I had not noticed this hold all. 
I don't use hold much, or plot. I usually end up tweaking each line saparately anyway, so I use line in the first place.</description>
		<content:encoded><![CDATA[<p>The colors of the lines in the legend of the last example are correct in 2008b and 2009a. Something else must have happened in the example here.<br />
The line styles and colors seem to get updated automatically in the legend if changed.<br />
FaceAplha of patch objects is not updated in legend though</p>
<p>Anyway, nice to know I had not noticed this hold all.<br />
I don&#8217;t use hold much, or plot. I usually end up tweaking each line saparately anyway, so I use line in the first place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30363</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 04 Jun 2009 11:19:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30363</guid>
		<description>Harald-

If you get the handles to the plots, e.g.,

&lt;pre&gt;
hold on
h1 = plot(....)
h2 = plot(...,'r')
&lt;/pre&gt;

then you can just use delete to get rid of the lines you don't want, e.g., 

&lt;pre&gt;
delete(h2)
&lt;/pre&gt;

With different scale data, you might want to try plotyy as well.

--Loren</description>
		<content:encoded><![CDATA[<p>Harald-</p>
<p>If you get the handles to the plots, e.g.,</p>
<pre>
hold on
h1 = plot(....)
h2 = plot(...,'r')
</pre>
<p>then you can just use delete to get rid of the lines you don&#8217;t want, e.g., </p>
<pre>
delete(h2)
</pre>
<p>With different scale data, you might want to try plotyy as well.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Pobloth</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30362</link>
		<dc:creator>Harald Pobloth</dc:creator>
		<pubDate>Thu, 04 Jun 2009 10:42:48 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30362</guid>
		<description>Hej Loreen,

first of all thanks for the blog, I appreciate your ideas and tips.

When I read this one I thought I could ask a question that is related but is not quite congruent.

The situation I fac quite frequently is that I plot two sets of data  to compare like this:
&lt;pre&gt;
plot(time1,data1)
hold on
plot(time2,data2,'r')
&lt;/pre&gt;

I am not all that itchy about the exact colors and things. However, what frequently happens is that data1 and data2 are scaled differently so data2 reners data1 as a flat line in the plot, another thing is that time1 and time2 might be different units (time1 in sceonds time2 in ms).

The only solutions I know of so far are a) be really careful before you plot (well ...) b) start over again with clf.

What I am looking for would be some "undo" command that removes the effect of the last plot command so I could do

&lt;pre&gt;
plot(time1,data1)
hold on
plot(time2,data2,'r')

UNDO THE LAST PLOT

data2 = scale_function(data2);
plot(time2,data2,'r')
&lt;/pre&gt;

This would be especially convenient in situations where data1 gets erased from memory or is in different levels of memory.

Cheers
Harald</description>
		<content:encoded><![CDATA[<p>Hej Loreen,</p>
<p>first of all thanks for the blog, I appreciate your ideas and tips.</p>
<p>When I read this one I thought I could ask a question that is related but is not quite congruent.</p>
<p>The situation I fac quite frequently is that I plot two sets of data  to compare like this:</p>
<pre>
plot(time1,data1)
hold on
plot(time2,data2,'r')
</pre>
<p>I am not all that itchy about the exact colors and things. However, what frequently happens is that data1 and data2 are scaled differently so data2 reners data1 as a flat line in the plot, another thing is that time1 and time2 might be different units (time1 in sceonds time2 in ms).</p>
<p>The only solutions I know of so far are a) be really careful before you plot (well &#8230;) b) start over again with clf.</p>
<p>What I am looking for would be some &#8220;undo&#8221; command that removes the effect of the last plot command so I could do</p>
<pre>
plot(time1,data1)
hold on
plot(time2,data2,'r')

UNDO THE LAST PLOT

data2 = scale_function(data2);
plot(time2,data2,'r')
</pre>
<p>This would be especially convenient in situations where data1 gets erased from memory or is in different levels of memory.</p>
<p>Cheers<br />
Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thierry Dalon</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30361</link>
		<dc:creator>Thierry Dalon</dc:creator>
		<pubDate>Thu, 04 Jun 2009 08:04:02 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30361</guid>
		<description>Hi
I've run the last example on R2008a and the legend on the figure is ok (blue and green).
Maybe it is in the html/screenshot generation that it went wrong?
---
Thanks for the plot Loren. I think there are quite a fiew FEX contributions to plot with automatic color cycling (see ex. plota). They were useful before hold got the option ALL!

-Thierry</description>
		<content:encoded><![CDATA[<p>Hi<br />
I&#8217;ve run the last example on R2008a and the legend on the figure is ok (blue and green).<br />
Maybe it is in the html/screenshot generation that it went wrong?<br />
&#8212;<br />
Thanks for the plot Loren. I think there are quite a fiew FEX contributions to plot with automatic color cycling (see ex. plota). They were useful before hold got the option ALL!</p>
<p>-Thierry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petter</title>
		<link>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30360</link>
		<dc:creator>Petter</dc:creator>
		<pubDate>Thu, 04 Jun 2009 07:18:31 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2009/06/03/hold-everything/#comment-30360</guid>
		<description>The legend colors are correct in 2007b.</description>
		<content:encoded><![CDATA[<p>The legend colors are correct in 2007b.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
