ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Jan 2017 09:54:18 -0600Legend for histogramhttp://ask.sagemath.org/question/36210/legend-for-histogram/I can't make the legend for histograms work as I want it to. I can make a legend with the labels appear but the corresponding indicator doesn't show the colors just two black vertical lines.
Here's a minimial example:
d1=[randint(0,10) for i in range(20)]
d2=[randint(0,10) for i in range(20)]
h=histogram([d1,d2],label=["d1","d2"])
h.legend(True)
h
Any ideas?Sat, 07 Jan 2017 05:21:19 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/Answer by paulmasson for <p>I can't make the legend for histograms work as I want it to. I can make a legend with the labels appear but the corresponding indicator doesn't show the colors just two black vertical lines.</p>
<p>Here's a minimial example:</p>
<pre><code>d1=[randint(0,10) for i in range(20)]
d2=[randint(0,10) for i in range(20)]
h=histogram([d1,d2],label=["d1","d2"])
h.legend(True)
h
</code></pre>
<p>Any ideas?</p>
http://ask.sagemath.org/question/36210/legend-for-histogram/?answer=36219#post-id-36219The colors are there but hidden by the indicator borders. Increase their size with
h.set_legend_options(handlelength=1)Sat, 07 Jan 2017 13:54:23 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/?answer=36219#post-id-36219Comment by kcrisman for <p>The colors are there but hidden by the indicator borders. Increase their size with</p>
<pre><code>h.set_legend_options(handlelength=1)
</code></pre>
http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36232#post-id-36232Probably; http://matplotlib.org/api/legend_api.html#matplotlib.legend.Legend says, "The pad and spacing parameters are measured in font-size units. e.g., a fontsize of 10 points and a handlelength=5 implies a handlelength of 50 points."Mon, 09 Jan 2017 09:54:18 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36232#post-id-36232Comment by tmonteil for <p>The colors are there but hidden by the indicator borders. Increase their size with</p>
<pre><code>h.set_legend_options(handlelength=1)
</code></pre>
http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36223#post-id-36223Great. Should a nonzero value set by default ? Or does this has effect somewhere else ?Sun, 08 Jan 2017 09:38:52 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36223#post-id-36223Comment by Acksl for <p>The colors are there but hidden by the indicator borders. Increase their size with</p>
<pre><code>h.set_legend_options(handlelength=1)
</code></pre>
http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36222#post-id-36222Perfect, thanks! :)Sun, 08 Jan 2017 06:28:39 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36222#post-id-36222Comment by kcrisman for <p>The colors are there but hidden by the indicator borders. Increase their size with</p>
<pre><code>h.set_legend_options(handlelength=1)
</code></pre>
http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36221#post-id-36221Very nice - see also https://trac.sagemath.org/ticket/22151Sat, 07 Jan 2017 22:45:00 -0600http://ask.sagemath.org/question/36210/legend-for-histogram/?comment=36221#post-id-36221