You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<metaproperty="og:description" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a legend for categorical colours, a colorbar for continuous ones, and a channel legend for multichannel images. s..." />
14
+
<metaproperty="og:description" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a categorical colour (named groups) gets a legend, a continuous colour (a numeric range) gets a colorbar, and a m..." />
<metaproperty="og:image:alt" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a legend for categorical colours, a colorbar for continuous ones, and a channel legend for multichannel images. s..." />
19
-
<metaname="description" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a legend for categorical colours, a colorbar for continuous ones, and a channel legend for multichannel images. s..." />
<metaproperty="og:image:alt" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a categorical colour (named groups) gets a legend, a continuous colour (a numeric range) gets a colorbar, and a m..." />
19
+
<metaname="description" content="Every coloured plot needs a key. spatialdata-plot builds three kinds automatically: a categorical colour (named groups) gets a legend, a continuous colour (a numeric range) gets a colorbar, and a m..." />
<h1>Legends and colorbars in spatialdata-plot<aclass="headerlink" href="#legends-and-colorbars-in-spatialdata-plot" title="Link to this heading">#</a></h1>
434
-
<p>Every coloured plot needs a key. <codeclass="docutils literal notranslate"><spanclass="pre">spatialdata-plot</span></code> builds three kinds automatically: a <strong>legend</strong> for
435
-
categorical colours, a <strong>colorbar</strong> for continuous ones, and a <strong>channel legend</strong> for multichannel
436
-
images. <codeclass="docutils literal notranslate"><spanclass="pre">show()</span></code> exposes a family of arguments to place and style each. By the end you should be able
434
+
<p>Every coloured plot needs a key. <codeclass="docutils literal notranslate"><spanclass="pre">spatialdata-plot</span></code> builds three kinds automatically: a <strong>categorical</strong> colour (named groups) gets a
435
+
<strong>legend</strong>, a <strong>continuous</strong> colour (a numeric range) gets a <strong>colorbar</strong>, and a multichannel image
436
+
gets a <strong>channel legend</strong>. <codeclass="docutils literal notranslate"><spanclass="pre">show()</span></code> places and styles the legend and colorbar; the channel legend is
437
+
switched on with <codeclass="docutils literal notranslate"><spanclass="pre">render_images(channels_as_legend=True)</span></code>. By the end you should be able
437
438
to:</p>
438
439
<ulclass="simple">
439
440
<li><p>Place a categorical legend anywhere (<codeclass="docutils literal notranslate"><spanclass="pre">legend_loc</span></code>) and restyle it (<codeclass="docutils literal notranslate"><spanclass="pre">legend_fontsize</span></code>,
@@ -544,8 +545,8 @@ <h2>3. Restyling the legend<a class="headerlink" href="#restyling-the-legend" ti
544
545
</section>
545
546
<sectionid="hiding-na-na-in-legend">
546
547
<h2>4. Hiding NA — <codeclass="docutils literal notranslate"><spanclass="pre">na_in_legend</span></code><aclass="headerlink" href="#hiding-na-na-in-legend" title="Link to this heading">#</a></h2>
547
-
<p>When you restrict to a few <codeclass="docutils literal notranslate"><spanclass="pre">groups</span></code>, the remaining spots become NA; <codeclass="docutils literal notranslate"><spanclass="pre">na_in_legend=False</span></code> drops that
548
-
entry from the key.</p>
548
+
<p><codeclass="docutils literal notranslate"><spanclass="pre">groups</span></code> subsets a categorical colour to the named categories; the remaining spots become NA, and
549
+
<codeclass="docutils literal notranslate"><spanclass="pre">na_in_legend=False</span></code> drops that NA entry from the key.</p>
<p>Instead of the flat <codeclass="docutils literal notranslate"><spanclass="pre">legend_*</span></code> kwargs you can pass one <codeclass="docutils literal notranslate"><spanclass="pre">legend_params</span></code> dict. Accepted keys:
matching flat kwargs, and unknown keys raise an error.</p>
569
+
<p>Note <codeclass="docutils literal notranslate"><spanclass="pre">legend_title</span></code> is <strong>not</strong> among the accepted keys — keep it as a flat <codeclass="docutils literal notranslate"><spanclass="pre">legend_title=</span></code> kwarg.</p>
<h2>7. Placing and styling the colorbar — <codeclass="docutils literal notranslate"><spanclass="pre">colorbar_params</span></code><aclass="headerlink" href="#placing-and-styling-the-colorbar-colorbar-params" title="Link to this heading">#</a></h2>
<codeclass="docutils literal notranslate"><spanclass="pre">orientation</span></code>). Move the bar below the plot and give it a label, or dock it to a different side.</p>
<codeclass="docutils literal notranslate"><spanclass="pre">"bottom"</span></code>), <codeclass="docutils literal notranslate"><spanclass="pre">width</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">pad</span></code>, plus matplotlib colorbar keys. Set <codeclass="docutils literal notranslate"><spanclass="pre">loc</span></code> to move the bar; its orientation
608
+
follows the side automatically (horizontal for top/bottom). Passing only <codeclass="docutils literal notranslate"><spanclass="pre">orientation</span></code> does <strong>not</strong>
@@ -672,7 +676,8 @@ <h2>Summary<a class="headerlink" href="#summary" title="Link to this heading">#<
672
676
<li><p>Place the legend with <codeclass="docutils literal notranslate"><spanclass="pre">legend_loc</span></code> (matplotlib locations <em>or</em><codeclass="docutils literal notranslate"><spanclass="pre">"right</span><spanclass="pre">margin"</span></code>), and style it with
673
677
<codeclass="docutils literal notranslate"><spanclass="pre">legend_fontsize</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">fontweight</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">fontoutline</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">legend_title</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">na_in_legend</span></code>; or bundle in
<li><p>Place and style the colorbar with <codeclass="docutils literal notranslate"><spanclass="pre">colorbar_params</span></code> (<codeclass="docutils literal notranslate"><spanclass="pre">label</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">loc</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">width</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">pad</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">orientation</span></code>).</p></li>
679
+
<li><p>Place and style the colorbar with <codeclass="docutils literal notranslate"><spanclass="pre">colorbar_params</span></code>; <codeclass="docutils literal notranslate"><spanclass="pre">loc</span></code> (<codeclass="docutils literal notranslate"><spanclass="pre">"right"</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">"left"</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">"top"</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">"bottom"</span></code>)
680
+
sets its position and the orientation follows.</p></li>
676
681
<li><p>In a multi-panel <codeclass="docutils literal notranslate"><spanclass="pre">color=[...]</span></code> figure each panel gets the appropriate key.</p></li>
0 commit comments