Skip to content

Commit f477b77

Browse files
committed
Preview for PR #15 a2db1f6
1 parent 97708a2 commit f477b77

5 files changed

Lines changed: 114 additions & 110 deletions

File tree

37.6 KB
Loading
832 KB
Loading

pr-15/_sources/notebooks/tutorials/as_points.ipynb

Lines changed: 94 additions & 92 deletions
Large diffs are not rendered by default.

pr-15/notebooks/tutorials/as_points.html

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -637,23 +637,25 @@ <h2>4. The speed trade-off<a class="headerlink" href="#the-speed-trade-off" titl
637637
<p>First, the whole section drawn both ways: all 167780 cells, coloured by EPCAM. At
638638
this zoom each cell is only a few microns across, well under one pixel, so the
639639
full-geometry circles render sparse and speckled while <code class="docutils literal notranslate"><span class="pre">as_points</span></code> spreads each
640-
cell into a visible marker. The centroid view is the cleaner overview here, and,
641-
as the timings below show, much the faster one.</p>
640+
cell into a visible marker. On the datashader backend <code class="docutils literal notranslate"><span class="pre">size</span></code> sets how far each
641+
dot spreads, so a larger value fills the gaps into continuous coverage. The
642+
centroid view is the cleaner overview here, and, as the timings below show, much
643+
the faster one.</p>
642644
<div class="cell docutils container">
643645
<div class="cell_input docutils container">
644646
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">fig</span><span class="p">,</span> <span class="n">axes</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mf">5.5</span><span class="p">))</span>
645647
<span class="n">sdata</span><span class="o">.</span><span class="n">pl</span><span class="o">.</span><span class="n">render_shapes</span><span class="p">(</span>
646648
<span class="s2">&quot;cell_circles&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;EPCAM&quot;</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="s2">&quot;magma&quot;</span><span class="p">,</span> <span class="n">outline_alpha</span><span class="o">=</span><span class="mf">0.0</span>
647649
<span class="p">)</span><span class="o">.</span><span class="n">pl</span><span class="o">.</span><span class="n">show</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">axes</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;full geometry (167780 circles)&quot;</span><span class="p">,</span> <span class="n">colorbar</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
648650
<span class="n">sdata</span><span class="o">.</span><span class="n">pl</span><span class="o">.</span><span class="n">render_shapes</span><span class="p">(</span>
649-
<span class="s2">&quot;cell_circles&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;EPCAM&quot;</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="s2">&quot;magma&quot;</span><span class="p">,</span> <span class="n">as_points</span><span class="o">=</span><span class="kc">True</span>
651+
<span class="s2">&quot;cell_circles&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;EPCAM&quot;</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="s2">&quot;magma&quot;</span><span class="p">,</span> <span class="n">as_points</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s2">&quot;datashader&quot;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">12</span>
650652
<span class="p">)</span><span class="o">.</span><span class="n">pl</span><span class="o">.</span><span class="n">show</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">axes</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">title</span><span class="o">=</span><span class="s2">&quot;as_points (167780 dots)&quot;</span><span class="p">,</span> <span class="n">colorbar</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
651653
<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
652654
</pre></div>
653655
</div>
654656
</div>
655657
<div class="cell_output docutils container">
656-
<img alt="../../_images/e12e47aebe090e5abb24801680c15c37b701bb88ca3729c4513945204a7433c1.png" src="../../_images/e12e47aebe090e5abb24801680c15c37b701bb88ca3729c4513945204a7433c1.png" />
658+
<img alt="../../_images/855c78a30dd38c3528985c35cc96e52656289abe0ca81ab6881bb6c162f740e3.png" src="../../_images/855c78a30dd38c3528985c35cc96e52656289abe0ca81ab6881bb6c162f740e3.png" />
657659
</div>
658660
</div>
659661
<p>To put numbers on it, we subsample the real cells across a range of counts, up to
@@ -692,12 +694,12 @@ <h2>4. The speed trade-off<a class="headerlink" href="#the-speed-trade-off" titl
692694
</div>
693695
</div>
694696
<div class="cell_output docutils container">
695-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>N= 1000: full 0.03s as_points 0.01s (4x)
696-
N= 5000: full 0.13s as_points 0.02s (8x)
697-
N= 20000: full 0.50s as_points 0.04s (13x)
698-
N= 50000: full 1.23s as_points 0.09s (14x)
699-
N= 100000: full 2.48s as_points 0.17s (15x)
700-
N= 167780: full 4.15s as_points 0.27s (16x)
697+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>N= 1000: full 0.03s as_points 0.01s (3x)
698+
N= 5000: full 0.13s as_points 0.02s (9x)
699+
N= 20000: full 0.52s as_points 0.04s (13x)
700+
N= 50000: full 1.26s as_points 0.09s (15x)
701+
N= 100000: full 2.54s as_points 0.17s (15x)
702+
N= 167780: full 4.23s as_points 0.26s (16x)
701703
</pre></div>
702704
</div>
703705
</div>
@@ -734,10 +736,10 @@ <h2>4. The speed trade-off<a class="headerlink" href="#the-speed-trade-off" titl
734736
</div>
735737
</div>
736738
<div class="cell_output docutils container">
737-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>N= 424: full mask 0.09s as_points 0.09s
739+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>N= 424: full mask 0.10s as_points 0.09s
738740
N= 5833: full mask 0.10s as_points 0.10s
739741
N= 18606: full mask 0.12s as_points 0.12s
740-
N= 39125: full mask 0.15s as_points 0.15s
742+
N= 39125: full mask 0.17s as_points 0.15s
741743
</pre></div>
742744
</div>
743745
</div>
@@ -763,7 +765,7 @@ <h2>4. The speed trade-off<a class="headerlink" href="#the-speed-trade-off" titl
763765
</div>
764766
</div>
765767
<div class="cell_output docutils container">
766-
<img alt="../../_images/de59cbe19573655e864703983ac44f0046efcf54ff6bc63f7788fab428a29a51.png" src="../../_images/de59cbe19573655e864703983ac44f0046efcf54ff6bc63f7788fab428a29a51.png" />
768+
<img alt="../../_images/22ae510ed0e3f6e3afdb800839f28d1bd202a8f51cb3b517864df6d2a569f9cf.png" src="../../_images/22ae510ed0e3f6e3afdb800839f28d1bd202a8f51cb3b517864df6d2a569f9cf.png" />
767769
</div>
768770
</div>
769771
<p>The two panels behave differently:</p>
@@ -791,10 +793,10 @@ <h2>5. Backend and the 50000 rule<a class="headerlink" href="#backend-and-the-50
791793
centroids (<code class="docutils literal notranslate"><span class="pre">AS_POINTS_DS_AUTO</span> <span class="pre">=</span> <span class="pre">50000</span></code>), because matplotlib’s per-glyph cost
792794
starts to dominate around there.</p></li>
793795
</ul>
794-
<p>The full-section <code class="docutils literal notranslate"><span class="pre">as_points</span></code> panel above used the default, so with 167780 cells
795-
it was already drawn by datashader. Passing <code class="docutils literal notranslate"><span class="pre">method=&quot;matplotlib&quot;</span></code> would force
796-
per-glyph scatter instead, and <code class="docutils literal notranslate"><span class="pre">method=&quot;datashader&quot;</span></code> forces the raster at any
797-
size.</p>
796+
<p>The full-section <code class="docutils literal notranslate"><span class="pre">as_points</span></code> panel above uses the datashader backend, which is
797+
also what the default selects above 50000 cells. Passing <code class="docutils literal notranslate"><span class="pre">method=&quot;matplotlib&quot;</span></code>
798+
forces per-glyph scatter instead, one marker per cell; <code class="docutils literal notranslate"><span class="pre">method=&quot;datashader&quot;</span></code>
799+
forces the raster at any size.</p>
798800
<p>datashader aggregates and then shades, so it cannot represent one distinct random
799801
colour per cell, which is the default colouring of a labels element with no
800802
colour column. In that case it falls back to matplotlib with a warning.</p>

pr-15/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)