snipt

Ctrl+h for KB shortcuts

Python

Legend with only one marker in Matplotlib

1
2
3
4
5
#for markers
legend(numpoints = 1)

#for scatter
legend(scatterpoints = 1)
https://snipt.net/embed/9cab831021c7af9ee84da1b6750a231a/
/raw/9cab831021c7af9ee84da1b6750a231a/
9cab831021c7af9ee84da1b6750a231a
python
Python
5
2019-08-17T20:17:05
True
False
False
/api/public/snipt/50698/
legend-with-only-one-marker-in-matplotlib
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">#for markers</span> </span><span id="L-2"><a name="L-2"></a><span class="n">legend</span><span class="p">(</span><span class="n">numpoints</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">#for scatter</span> </span><span id="L-5"><a name="L-5"></a><span class="n">legend</span><span class="p">(</span><span class="n">scatterpoints</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> </span></pre></div> </td></tr></table>
Matplotlib, legend, scatter