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-21T21:04:34
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

S

ggplot point with shape and facet wrap

1
2
3
4
# simple example
gp <- ggplot(data , aes(x=datax,y=datay,color=datacolor, shape=datashpae)) + geom_point()
gp + facet_wrap(~var1,scales='free') +opts(title='Vary Delay to Other Patch')
ggsave('data_summary_allSub_v1.png')
https://snipt.net/embed/9332e37dd6311a8c44e32f322c3a16c0/
/raw/9332e37dd6311a8c44e32f322c3a16c0/
9332e37dd6311a8c44e32f322c3a16c0
splus
S
6
2019-08-22T06:01:12
True
False
False
/api/public/snipt/28964/
ggplot-point-with-shape-and-facet-wrap
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># simple example</span> </span><span id="L-2"><a name="L-2"></a>gp <span class="o">&lt;-</span> ggplot<span class="p">(</span>data <span class="p">,</span> aes<span class="p">(</span>x<span class="o">=</span>datax<span class="p">,</span>y<span class="o">=</span>datay<span class="p">,</span>color<span class="o">=</span>datacolor<span class="p">,</span> shape<span class="o">=</span>datashpae<span class="p">))</span> <span class="o">+</span> geom_point<span class="p">()</span> </span><span id="L-3"><a name="L-3"></a>gp <span class="o">+</span> facet_wrap<span class="p">(</span><span class="o">~</span>var1<span class="p">,</span>scales<span class="o">=</span><span class="s">&#39;free&#39;</span><span class="p">)</span> <span class="o">+</span>opts<span class="p">(</span>title<span class="o">=</span><span class="s">&#39;Vary Delay to Other Patch&#39;</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a>ggsave<span class="p">(</span><span class="s">&#39;data_summary_allSub_v1.png&#39;</span><span class="p">)</span> </span></pre></div> </td></tr></table>
facet, ggplot, graph, plot, r, scatter