<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Plot legend customization	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/plot-legend-customization/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/plot-legend-customization?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=plot-legend-customization</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Wed, 15 Jun 2022 04:35:37 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Gres		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-514248</link>

		<dc:creator><![CDATA[Gres]]></dc:creator>
		<pubDate>Wed, 15 Jun 2022 04:35:37 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-514248</guid>

					<description><![CDATA[In 2018b, you can get the icons by calling [hh,icons,plots,txt] = legend({&#039;Line 1&#039;});]]></description>
			<content:encoded><![CDATA[<p>In 2018b, you can get the icons by calling [hh,icons,plots,txt] = legend({&#8216;Line 1&#8217;});</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dev		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-484625</link>

		<dc:creator><![CDATA[Dev]]></dc:creator>
		<pubDate>Tue, 25 Jun 2019 11:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-484625</guid>

					<description><![CDATA[Same question as sco1: Have you had luck utilizing NodeChildren to perform similar options in MATLAB &#062;= R2017a?]]></description>
			<content:encoded><![CDATA[<p>Same question as sco1: Have you had luck utilizing NodeChildren to perform similar options in MATLAB &gt;= R2017a?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-471160</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 29 Mar 2019 13:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-471160</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/plot-legend-customization#comment-470683&quot;&gt;Praveen&lt;/a&gt;.

@Praveen - first note that you have to call &lt;i&gt;&lt;b&gt;drawnow&lt;/b&gt;&lt;/i&gt; before accessing any of the internal legend components. In addition, note that &lt;code&gt;hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children&lt;/code&gt; returns an array of objects (&lt;code&gt;Marker&lt;/code&gt; and &lt;code&gt;LineStrip&lt;/code&gt;) and you can only set the &lt;b&gt;Size&lt;/b&gt; property of the &lt;code&gt;Marker&lt;/code&gt;, not the &lt;code&gt;LineStrip&lt;/code&gt; (duh). Here&#039;s a working example:
&lt;pre lang=&quot;matlab&quot;&gt;
figure; hold all;
hLine1 = plot(1:5,&#039;o-b&#039;); 
hLine2 = plot(2:6,&#039;-sr&#039;);
hLegend = legend([hLine1,hLine2], &#039;Location&#039;,&#039;SouthEast&#039;);
hLegend.Title.String = &#039;MyLegend&#039;;
drawnow;
hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children(1).Size = 15;
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/plot-legend-customization#comment-470683">Praveen</a>.</p>
<p>@Praveen &#8211; first note that you have to call <i><b>drawnow</b></i> before accessing any of the internal legend components. In addition, note that <code>hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children</code> returns an array of objects (<code>Marker</code> and <code>LineStrip</code>) and you can only set the <b>Size</b> property of the <code>Marker</code>, not the <code>LineStrip</code> (duh). Here&#8217;s a working example:</p>
<pre lang="matlab">
figure; hold all;
hLine1 = plot(1:5,'o-b'); 
hLine2 = plot(2:6,'-sr');
hLegend = legend([hLine1,hLine2], 'Location','SouthEast');
hLegend.Title.String = 'MyLegend';
drawnow;
hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children(1).Size = 15;
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Praveen		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-470683</link>

		<dc:creator><![CDATA[Praveen]]></dc:creator>
		<pubDate>Wed, 27 Mar 2019 17:55:23 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-470683</guid>

					<description><![CDATA[Hi That&#039;s alright, how do I set for example, marker size in the legend, when I try to set it: &lt;code&gt;hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children.Size = 15;&lt;/code&gt; I get an error saying I can&#039;t set readonly properties, any tips how to go about that. Thanks]]></description>
			<content:encoded><![CDATA[<p>Hi That&#8217;s alright, how do I set for example, marker size in the legend, when I try to set it: <code>hLegend.EntryContainer.NodeChildren(1).Icon.Transform.Children.Children.Size = 15;</code> I get an error saying I can&#8217;t set readonly properties, any tips how to go about that. Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Aaron		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-466218</link>

		<dc:creator><![CDATA[Aaron]]></dc:creator>
		<pubDate>Fri, 08 Mar 2019 11:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-466218</guid>

					<description><![CDATA[It would appear that if you&#039;re using these properties in a function or loop it is important to call &lt;code&gt;drawnow&lt;/code&gt; before attempting to utilise any of the &lt;code&gt;LegendEntry&lt;/code&gt; objects, otherwise they will not exist yet and you will get errors.]]></description>
			<content:encoded><![CDATA[<p>It would appear that if you&#8217;re using these properties in a function or loop it is important to call <code>drawnow</code> before attempting to utilise any of the <code>LegendEntry</code> objects, otherwise they will not exist yet and you will get errors.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-432760</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 18 Jul 2018 07:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-432760</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/plot-legend-customization#comment-432669&quot;&gt;Peter Cook&lt;/a&gt;.

@Peter - while the legend object&#039;s &lt;b&gt;ItemHitFcn&lt;/b&gt; callback property is &lt;a href=&quot;https://www.mathworks.com/help/matlab/ref/matlab.graphics.illustration.legend-properties.html#propname_ItemHitFcn&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;documented/supported&lt;/a&gt;, the &lt;b&gt;Item&lt;/b&gt; property of the &lt;code&gt;eventData&lt;/code&gt; object (which is passed to the callback function in run-time when you click a legend entry) is indeed hidden/undocumented. This &lt;code&gt;eventData.Item&lt;/code&gt; property contains the &lt;code&gt;LegendEntry&lt;/code&gt; item that was clicked. Thanks for pointing it out.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/plot-legend-customization#comment-432669">Peter Cook</a>.</p>
<p>@Peter &#8211; while the legend object&#8217;s <b>ItemHitFcn</b> callback property is <a href="https://www.mathworks.com/help/matlab/ref/matlab.graphics.illustration.legend-properties.html#propname_ItemHitFcn" target="_blank" rel="nofollow">documented/supported</a>, the <b>Item</b> property of the <code>eventData</code> object (which is passed to the callback function in run-time when you click a legend entry) is indeed hidden/undocumented. This <code>eventData.Item</code> property contains the <code>LegendEntry</code> item that was clicked. Thanks for pointing it out.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peter Cook		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-432669</link>

		<dc:creator><![CDATA[Peter Cook]]></dc:creator>
		<pubDate>Tue, 17 Jul 2018 15:17:11 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-432669</guid>

					<description><![CDATA[I have recently incorporated the Legend&#039;s &lt;code&gt;ItemHitFcn&lt;/code&gt; callback property into a utility I built.
You can access and edit some relevant objects in the callback function, e.g.

&lt;pre lang=&quot;matlab&quot;&gt;
hLegend.ItemHitFcn = myLegendItemHitFcn(src,evnt);

% The following in the callback function:
evnt.Peer %access line, patch, image, GraphPlot, etc... 
evnt.Item.Label %access text object for that legend entry
src.String{evnt.Item.Index} = &#039;new string&#039;; %edit the legend entry name
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>I have recently incorporated the Legend&#8217;s <code>ItemHitFcn</code> callback property into a utility I built.<br />
You can access and edit some relevant objects in the callback function, e.g.</p>
<pre lang="matlab">
hLegend.ItemHitFcn = myLegendItemHitFcn(src,evnt);

% The following in the callback function:
evnt.Peer %access line, patch, image, GraphPlot, etc... 
evnt.Item.Label %access text object for that legend entry
src.String{evnt.Item.Index} = 'new string'; %edit the legend entry name
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sco1		</title>
		<link>https://undocumentedmatlab.com/articles/plot-legend-customization#comment-432282</link>

		<dc:creator><![CDATA[sco1]]></dc:creator>
		<pubDate>Fri, 13 Jul 2018 01:40:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=7744#comment-432282</guid>

					<description><![CDATA[Very interesting! I never explored &lt;code&gt;NodeChildren&lt;/code&gt; when I was building &lt;a href=&quot;https://github.com/StackOverflowMATLABchat/legtools&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;legtools&lt;/code&gt;&lt;/a&gt; and was using &lt;code&gt;PlotChildren&lt;/code&gt; instead to do things like rearrange the legend, add/remove entries, etc. 

Have you had luck utilizing &lt;code&gt;NodeChildren&lt;/code&gt; to perform similar options in MATLAB &#062;= R2017a? 
R2017a introduced &lt;code&gt;AutoUpdate&lt;/code&gt; to &lt;code&gt;legend&lt;/code&gt; objects which broke pretty much all of the functionality I got from manipulating &lt;code&gt;PlotChildren&lt;/code&gt;.]]></description>
			<content:encoded><![CDATA[<p>Very interesting! I never explored <code>NodeChildren</code> when I was building <a href="https://github.com/StackOverflowMATLABchat/legtools" rel="nofollow"><code>legtools</code></a> and was using <code>PlotChildren</code> instead to do things like rearrange the legend, add/remove entries, etc. </p>
<p>Have you had luck utilizing <code>NodeChildren</code> to perform similar options in MATLAB &gt;= R2017a?<br />
R2017a introduced <code>AutoUpdate</code> to <code>legend</code> objects which broke pretty much all of the functionality I got from manipulating <code>PlotChildren</code>.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
