Skip to content

Commit bd2c675

Browse files
committed
Preview for PR #12 8bfdc87
1 parent 7fe8590 commit bd2c675

10 files changed

Lines changed: 118 additions & 48 deletions
180 KB
Loading
181 KB
Loading
179 KB
Loading
179 KB
Loading
182 KB
Loading
182 KB
Loading

pr-12/_images/scalebars.png

-10.6 KB
Loading

pr-12/_sources/notebooks/tutorials/scalebars.ipynb

Lines changed: 83 additions & 36 deletions
Large diffs are not rendered by default.

pr-12/notebooks/tutorials/scalebars.html

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ <h2> Contents </h2>
351351
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#units-and-auto-scaling">2. Units and auto-scaling</a></li>
352352
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#placement-and-appearance-with-scalebar-params">3. Placement and appearance with <code class="docutils literal notranslate"><span class="pre">scalebar_params</span></code></a></li>
353353
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#pinning-an-exact-bar-length">4. Pinning an exact bar length</a></li>
354-
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#everything-else-and-on-real-data">5. Everything else, and on real data</a></li>
354+
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#rotating-the-bar-and-adding-a-label">5. Rotating the bar and adding a label</a></li>
355355
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#for-reproducibility">For reproducibility</a></li>
356356
</ul>
357357
</nav>
@@ -426,7 +426,7 @@ <h2>1. The one required piece: <code class="docutils literal notranslate"><span
426426
</div>
427427
</div>
428428
<div class="cell_output docutils container">
429-
<img alt="../../_images/4211da38c5feff24a3237793f9e7efb8375f096b1343779e6d6a2168e432061a.png" src="../../_images/4211da38c5feff24a3237793f9e7efb8375f096b1343779e6d6a2168e432061a.png" />
429+
<img alt="../../_images/4f92675a93795d4432bcab822724c9a4e590a37e88aeb83e676c6be86c1bb9ad.png" src="../../_images/4f92675a93795d4432bcab822724c9a4e590a37e88aeb83e676c6be86c1bb9ad.png" />
430430
</div>
431431
</div>
432432
<p>Without <code class="docutils literal notranslate"><span class="pre">scalebar_dx</span></code> there is <strong>no scalebar</strong> — the plot has no way to know the physical size, and it never guesses. Two things worth remembering:</p>
@@ -450,7 +450,7 @@ <h2>2. Units and auto-scaling<a class="headerlink" href="#units-and-auto-scaling
450450
</div>
451451
</div>
452452
<div class="cell_output docutils container">
453-
<img alt="../../_images/f1fecf885ca269dc570d82a633618ad578ee315afb6f95d7c8ceeb54fecec7fa.png" src="../../_images/f1fecf885ca269dc570d82a633618ad578ee315afb6f95d7c8ceeb54fecec7fa.png" />
453+
<img alt="../../_images/4d0aabe5fd25e99f61956f06f4719cd3eca27309e6e6954051e0478e970bddb0.png" src="../../_images/4d0aabe5fd25e99f61956f06f4719cd3eca27309e6e6954051e0478e970bddb0.png" />
454454
</div>
455455
</div>
456456
</section>
@@ -483,7 +483,7 @@ <h2>3. Placement and appearance with <code class="docutils literal notranslate">
483483
</div>
484484
</div>
485485
<div class="cell_output docutils container">
486-
<img alt="../../_images/15e2d4e50a68e7fae031293bf635518962aab85174676cbc4afcc9377c2ce88c.png" src="../../_images/15e2d4e50a68e7fae031293bf635518962aab85174676cbc4afcc9377c2ce88c.png" />
486+
<img alt="../../_images/db4dccbb20cc477c35bc2782911edfce2f384d67c4e1fd37d393f5c6786fcb84.png" src="../../_images/db4dccbb20cc477c35bc2782911edfce2f384d67c4e1fd37d393f5c6786fcb84.png" />
487487
</div>
488488
</div>
489489
<p>Font styling goes through <code class="docutils literal notranslate"><span class="pre">font_properties</span></code>, a matplotlib font dict:</p>
@@ -504,7 +504,7 @@ <h2>3. Placement and appearance with <code class="docutils literal notranslate">
504504
</div>
505505
</div>
506506
<div class="cell_output docutils container">
507-
<img alt="../../_images/ca7131b57c2ea1e2e9cae23d333f5b079f5094c4cd42fac6c19b8463cc5e5c75.png" src="../../_images/ca7131b57c2ea1e2e9cae23d333f5b079f5094c4cd42fac6c19b8463cc5e5c75.png" />
507+
<img alt="../../_images/d97fb0c1816c3af627c718b35cc5786927aac36391ab71493d67cd3a40858044.png" src="../../_images/d97fb0c1816c3af627c718b35cc5786927aac36391ab71493d67cd3a40858044.png" />
508508
</div>
509509
</div>
510510
</section>
@@ -529,14 +529,37 @@ <h2>4. Pinning an exact bar length<a class="headerlink" href="#pinning-an-exact-
529529
</div>
530530
</div>
531531
<div class="cell_output docutils container">
532-
<img alt="../../_images/92fec706a22c7aca3d3908c49bdd801580bdf8d1475d38fcd7078082037b2def.png" src="../../_images/92fec706a22c7aca3d3908c49bdd801580bdf8d1475d38fcd7078082037b2def.png" />
532+
<img alt="../../_images/126725ab7bb424c303a6de20791fc79166225c753e65efac3d1fcc4e6360df5b.png" src="../../_images/126725ab7bb424c303a6de20791fc79166225c753e65efac3d1fcc4e6360df5b.png" />
533533
</div>
534534
</div>
535535
</section>
536-
<section id="everything-else-and-on-real-data">
537-
<h2>5. Everything else, and on real data<a class="headerlink" href="#everything-else-and-on-real-data" title="Link to this heading">#</a></h2>
538-
<p>Because <code class="docutils literal notranslate"><span class="pre">scalebar_params</span></code> is forwarded to matplotlib-scalebar, anything that library supports (<code class="docutils literal notranslate"><span class="pre">rotation</span></code>, <code class="docutils literal notranslate"><span class="pre">width_fraction</span></code>, custom formatters, …) works too — see the <a class="reference external" href="https://github.com/ppinard/matplotlib-scalebar">matplotlib-scalebar documentation</a> for the full list.</p>
539-
<p>For a scalebar on a real dataset with a genuine micron-per-pixel value, see the <a class="reference internal" href="../examples/visium_mouse_brain.html"><span class="doc">Visium mouse brain example</span></a>, which finishes with a publication-style figure.</p>
536+
<section id="rotating-the-bar-and-adding-a-label">
537+
<h2>5. Rotating the bar and adding a label<a class="headerlink" href="#rotating-the-bar-and-adding-a-label" title="Link to this heading">#</a></h2>
538+
<p>Two more <code class="docutils literal notranslate"><span class="pre">scalebar_params</span></code> round things out. <code class="docutils literal notranslate"><span class="pre">rotation</span></code> (<code class="docutils literal notranslate"><span class="pre">&quot;horizontal&quot;</span></code> or <code class="docutils literal notranslate"><span class="pre">&quot;vertical&quot;</span></code>) turns the bar on its side — useful when the free space in a panel is a tall strip rather than a wide one. <code class="docutils literal notranslate"><span class="pre">label</span></code> adds your own text alongside the automatic value, effectively a title for the bar, and <code class="docutils literal notranslate"><span class="pre">label_loc</span></code> (<code class="docutils literal notranslate"><span class="pre">&quot;left&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;right&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;top&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;bottom&quot;</span></code>) places it relative to the bar.</p>
539+
<div class="cell docutils container">
540+
<div class="cell_input docutils container">
541+
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">sdata</span><span class="o">.</span><span class="n">pl</span><span class="o">.</span><span class="n">render_images</span><span class="p">(</span><span class="s2">&quot;blobs_image&quot;</span><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>
542+
<span class="n">scalebar_dx</span><span class="o">=</span><span class="n">PX_SIZE_UM</span><span class="p">,</span>
543+
<span class="n">scalebar_units</span><span class="o">=</span><span class="s2">&quot;um&quot;</span><span class="p">,</span>
544+
<span class="n">scalebar_params</span><span class="o">=</span><span class="p">{</span>
545+
<span class="s2">&quot;location&quot;</span><span class="p">:</span> <span class="s2">&quot;lower right&quot;</span><span class="p">,</span>
546+
<span class="s2">&quot;color&quot;</span><span class="p">:</span> <span class="s2">&quot;white&quot;</span><span class="p">,</span>
547+
<span class="s2">&quot;box_color&quot;</span><span class="p">:</span> <span class="s2">&quot;black&quot;</span><span class="p">,</span>
548+
<span class="s2">&quot;box_alpha&quot;</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span>
549+
<span class="s2">&quot;fixed_value&quot;</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span>
550+
<span class="s2">&quot;fixed_units&quot;</span><span class="p">:</span> <span class="s2">&quot;um&quot;</span><span class="p">,</span>
551+
<span class="s2">&quot;rotation&quot;</span><span class="p">:</span> <span class="s2">&quot;vertical&quot;</span><span class="p">,</span>
552+
<span class="s2">&quot;label&quot;</span><span class="p">:</span> <span class="s2">&quot;scale&quot;</span><span class="p">,</span>
553+
<span class="s2">&quot;label_loc&quot;</span><span class="p">:</span> <span class="s2">&quot;left&quot;</span><span class="p">,</span>
554+
<span class="p">},</span>
555+
<span class="p">)</span>
556+
</pre></div>
557+
</div>
558+
</div>
559+
<div class="cell_output docutils container">
560+
<img alt="../../_images/1b942c7e23bc179319e76a405c3b2b50ce41b4941ea6622604b460912923a120.png" src="../../_images/1b942c7e23bc179319e76a405c3b2b50ce41b4941ea6622604b460912923a120.png" />
561+
</div>
562+
</div>
540563
</section>
541564
<section id="for-reproducibility">
542565
<h2>For reproducibility<a class="headerlink" href="#for-reproducibility" title="Link to this heading">#</a></h2>
@@ -628,7 +651,7 @@ <h2>For reproducibility<a class="headerlink" href="#for-reproducibility" title="
628651
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#units-and-auto-scaling">2. Units and auto-scaling</a></li>
629652
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#placement-and-appearance-with-scalebar-params">3. Placement and appearance with <code class="docutils literal notranslate"><span class="pre">scalebar_params</span></code></a></li>
630653
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#pinning-an-exact-bar-length">4. Pinning an exact bar length</a></li>
631-
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#everything-else-and-on-real-data">5. Everything else, and on real data</a></li>
654+
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#rotating-the-bar-and-adding-a-label">5. Rotating the bar and adding a label</a></li>
632655
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#for-reproducibility">For reproducibility</a></li>
633656
</ul>
634657
</nav></div>

pr-12/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)