<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, How doi I insert a legend in a PieChart from the command lines?</title>
    <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 09:33:34 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 09:33:34 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, How doi I insert a legend in a PieChart from the command lines?</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, How doi I insert a legend in a PieChart from the command lines?</title>
      <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart</link>
    </image>
    <item>
      <title>How about this:</title>
      <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart?ref=Feed:MaplePrimes:How doi I insert a legend in a PieChart from the command lines?:Comments#answer95136</link>
      <itunes:summary>&lt;p&gt;PieChart and the like should really have a legend option, and maybe I will at some point get around to that. Until then, here is a command that will match the sectors up with the left hand sides of your list T:&lt;/p&gt;
&lt;pre&gt;Q := subs(zip((pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend)), select(type, [op(P)], specfunc(anything, POLYGONS)), map(lhs, T)), P):&lt;br&gt;plots[display](Q&lt;span class="mainBody document"&gt;, title = ["Distribuci&amp;oacute;n de las exportaciones de Chile en el a&amp;ntilde;o 2009", font = [TIMES, BOLD, 18]], font = [TIMES, BOLD, 12]);&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;This is not necessarily guaranteed to work in all cases, I'm afraid. Making a legend for the PieChart plot structure after the plot has been generated cannot really be done reliably. But still, it will work in a large number of cases in versions of Maple that are currently available - and it works for this particular plot in Maple 12.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Hope this helps,&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;PieChart and the like should really have a legend option, and maybe I will at some point get around to that. Until then, here is a command that will match the sectors up with the left hand sides of your list T:&lt;/p&gt;
&lt;pre&gt;Q := subs(zip((pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend)), select(type, [op(P)], specfunc(anything, POLYGONS)), map(lhs, T)), P):&lt;br&gt;plots[display](Q&lt;span class="mainBody document"&gt;, title = ["Distribuci&amp;oacute;n de las exportaciones de Chile en el a&amp;ntilde;o 2009", font = [TIMES, BOLD, 18]], font = [TIMES, BOLD, 12]);&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;This is not necessarily guaranteed to work in all cases, I'm afraid. Making a legend for the PieChart plot structure after the plot has been generated cannot really be done reliably. But still, it will work in a large number of cases in versions of Maple that are currently available - and it works for this particular plot in Maple 12.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Hope this helps,&lt;br&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <guid>95136</guid>
      <pubDate>Fri, 16 Jul 2010 00:28:59 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
    <item>
      <title>Another workaround</title>
      <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart?ref=Feed:MaplePrimes:How doi I insert a legend in a PieChart from the command lines?:Comments#answer95139</link>
      <itunes:summary>&lt;p&gt;Here's another possibility:&lt;/p&gt;
&lt;p&gt;Create a bunch of empty polygons having the same colours as those you've defined for the pie chart and include these in your plot.&lt;/p&gt;
&lt;p&gt;&amp;gt; colorlist := ["red", "Orange", ...];&lt;br&gt;&amp;gt; legendlist := ["first entry", "second entry", ...];&lt;br&gt;&amp;gt; p1 := plots[display](seq(plots[polygonplot]([[0,0],[0,0]], color=colorlist[i], legend=legendlist[i]), i=1..nops(colorlist))):&lt;br&gt;&amp;gt; plots[display](p1, p2);&lt;/p&gt;
&lt;p&gt;where p2 is the pie chart plot.&lt;/p&gt;
&lt;p&gt;Paulina&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Here's another possibility:&lt;/p&gt;
&lt;p&gt;Create a bunch of empty polygons having the same colours as those you've defined for the pie chart and include these in your plot.&lt;/p&gt;
&lt;p&gt;&amp;gt; colorlist := ["red", "Orange", ...];&lt;br&gt;&amp;gt; legendlist := ["first entry", "second entry", ...];&lt;br&gt;&amp;gt; p1 := plots[display](seq(plots[polygonplot]([[0,0],[0,0]], color=colorlist[i], legend=legendlist[i]), i=1..nops(colorlist))):&lt;br&gt;&amp;gt; plots[display](p1, p2);&lt;/p&gt;
&lt;p&gt;where p2 is the pie chart plot.&lt;/p&gt;
&lt;p&gt;Paulina&lt;/p&gt;</description>
      <guid>95139</guid>
      <pubDate>Fri, 16 Jul 2010 01:12:42 Z</pubDate>
      <itunes:author>pchin</itunes:author>
      <author>pchin</author>
    </item>
    <item>
      <title>Thank you very much, but I have a problem.</title>
      <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart?ref=Feed:MaplePrimes:How doi I insert a legend in a PieChart from the command lines?:Comments#comment95140</link>
      <itunes:summary>&lt;p&gt;Thank you very much, but I have a problem. I inserted the line:&lt;/p&gt;
&lt;pre&gt;Q := subs(zip((pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend)), select(type, [op(P)])))&lt;br&gt;&lt;br&gt;before of the "plots[display](Q,......), etc..&lt;br&gt;&lt;br&gt;and showed: "Error, incorrect number of extra arguments in select"&lt;br&gt;&lt;br&gt;I don't understand very much that line. Reading the Maple Help I could understand a little more, but it doesn't work...&lt;br&gt;&lt;br&gt;Can you still help?&lt;br&gt;&lt;br&gt;Thanks...&lt;br&gt;&lt;br&gt;MJ&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;Thank you very much, but I have a problem. I inserted the line:&lt;/p&gt;
&lt;pre&gt;Q := subs(zip((pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend)), select(type, [op(P)])))&lt;br&gt;&lt;br&gt;before of the "plots[display](Q,......), etc..&lt;br&gt;&lt;br&gt;and showed: "Error, incorrect number of extra arguments in select"&lt;br&gt;&lt;br&gt;I don't understand very much that line. Reading the Maple Help I could understand a little more, but it doesn't work...&lt;br&gt;&lt;br&gt;Can you still help?&lt;br&gt;&lt;br&gt;Thanks...&lt;br&gt;&lt;br&gt;MJ&lt;/pre&gt;</description>
      <guid>95140</guid>
      <pubDate>Fri, 16 Jul 2010 01:55:14 Z</pubDate>
      <itunes:author>pepa</itunes:author>
      <author>pepa</author>
    </item>
    <item>
      <title>Explanation</title>
      <link>http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart?ref=Feed:MaplePrimes:How doi I insert a legend in a PieChart from the command lines?:Comments#comment95169</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart#comment95140"&gt;@pepa&lt;/a&gt; : I'd recommend going with pchin's solution, which is more reliable.&lt;/p&gt;
&lt;p&gt;Just for people reading my comment above and wondering what's going on, a quick explanation. I'll repeat that this is not necessarily a reliable way to interact with plots; the data structure may change in future versions. That said, it may offer something useful to someone wanting to operate on &lt;em&gt;other&lt;/em&gt; Maple data structures; the same basic functions are useful elsewhere, of course.&lt;/p&gt;
&lt;p&gt;The easiest way to deal with these sorts of things is reading it starting from the inside. The innermost thing that makes sense by itself is&lt;/p&gt;
&lt;p&gt;select(type, [op(P)], specfunc(anything, POLYGONS));&lt;/p&gt;
&lt;p&gt;which returns the ordered list of all POLYGONS plot structures in P (see  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=type"&gt;?type&lt;/a&gt; and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=type/structure"&gt;?type/structure&lt;/a&gt;&amp;nbsp;and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=select"&gt;?select&lt;/a&gt;). Another subexpression on the same level is&lt;/p&gt;
&lt;p&gt;map(lhs, T);&lt;/p&gt;
&lt;p&gt;which returns all the left hand sides for the equations in T (see  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=map"&gt;?map&lt;/a&gt; and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=lhs"&gt;?lhs&lt;/a&gt;). There should be equally many of each. We apply &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=zip"&gt;?zip&lt;/a&gt;&amp;nbsp;to those two lists, and the function with which we zip them is custom: it's&lt;/p&gt;
&lt;p&gt;(pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend));&lt;/p&gt;
&lt;p&gt;which takes a POLYGONS plot structure and a legend argument (one from the first list constructed above, one from the second list) and creates from it an equation, where the left hand side is pol (the POLYGONS plot structure) and the right hand side is the same plot structure but with an extra argument: LEGEND(legend).&lt;/p&gt;
&lt;p&gt;The resulting list of equations is fed to  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=subs"&gt;?subs&lt;/a&gt;, so that it substitutes the version with the extra argument for the original version of each POLYGONS data structure, and that's it.&lt;/p&gt;
&lt;p&gt;I'll finish by repeating my recommendation that you use pchin's idea of adding a couple empty polygons with a legend, for the question you originally asked.&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/95132-How-Doi-I-Insert-A-Legend-In-A-PieChart#comment95140"&gt;@pepa&lt;/a&gt; : I'd recommend going with pchin's solution, which is more reliable.&lt;/p&gt;
&lt;p&gt;Just for people reading my comment above and wondering what's going on, a quick explanation. I'll repeat that this is not necessarily a reliable way to interact with plots; the data structure may change in future versions. That said, it may offer something useful to someone wanting to operate on &lt;em&gt;other&lt;/em&gt; Maple data structures; the same basic functions are useful elsewhere, of course.&lt;/p&gt;
&lt;p&gt;The easiest way to deal with these sorts of things is reading it starting from the inside. The innermost thing that makes sense by itself is&lt;/p&gt;
&lt;p&gt;select(type, [op(P)], specfunc(anything, POLYGONS));&lt;/p&gt;
&lt;p&gt;which returns the ordered list of all POLYGONS plot structures in P (see  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=type"&gt;?type&lt;/a&gt; and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=type/structure"&gt;?type/structure&lt;/a&gt;&amp;nbsp;and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=select"&gt;?select&lt;/a&gt;). Another subexpression on the same level is&lt;/p&gt;
&lt;p&gt;map(lhs, T);&lt;/p&gt;
&lt;p&gt;which returns all the left hand sides for the equations in T (see  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=map"&gt;?map&lt;/a&gt; and  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=lhs"&gt;?lhs&lt;/a&gt;). There should be equally many of each. We apply &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=zip"&gt;?zip&lt;/a&gt;&amp;nbsp;to those two lists, and the function with which we zip them is custom: it's&lt;/p&gt;
&lt;p&gt;(pol, legend) -&amp;gt; pol = op(0, pol)(op(pol), LEGEND(legend));&lt;/p&gt;
&lt;p&gt;which takes a POLYGONS plot structure and a legend argument (one from the first list constructed above, one from the second list) and creates from it an equation, where the left hand side is pol (the POLYGONS plot structure) and the right hand side is the same plot structure but with an extra argument: LEGEND(legend).&lt;/p&gt;
&lt;p&gt;The resulting list of equations is fed to  &lt;a href="http://www.maplesoft.com/support/help/view.aspx?path=subs"&gt;?subs&lt;/a&gt;, so that it substitutes the version with the extra argument for the original version of each POLYGONS data structure, and that's it.&lt;/p&gt;
&lt;p&gt;I'll finish by repeating my recommendation that you use pchin's idea of adding a couple empty polygons with a legend, for the question you originally asked.&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br&gt;Maplesoft.&lt;/p&gt;</description>
      <guid>95169</guid>
      <pubDate>Fri, 16 Jul 2010 22:12:39 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
  </channel>
</rss>