<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Py/Altair on serhii.net</title>
    <link>https://serhii.net/tags/py/altair/</link>
    <description>Recent content in Py/Altair on serhii.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>Serhii Hamotskyi / serhii.net</copyright>
    <lastBuildDate>Mon, 21 Sep 2026 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://serhii.net/tags/py/altair/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Vega Altair visualization notes</title>
      <link>https://serhii.net/dtb/260921-2203-vega-altair-visualization-notes/</link>
      <pubDate>Mon, 21 Sep 2026 00:00:00 +0200</pubDate>
      <guid>https://serhii.net/dtb/260921-2203-vega-altair-visualization-notes/</guid>
      <description>&lt;h3 id=&#34;config&#34;&gt;Config&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/configuration.html&#34;&gt;Top-Level Chart Configuration — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&#xA;All together with .properties on the Chart object itsel:&#xA;&lt;code&gt;alt.Chart().encode().properties().top_level_configuration_item()&lt;/code&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;etc&#34;&gt;Etc&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/encodings/index.html#encoding-data-types&#34;&gt;Encodings — Vega-Altair&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Channels (x,y etc.): &lt;a href=&#34;https://altair-viz.github.io/user_guide/encodings/channels.html&#34;&gt;Channels — Vega-Altair&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Encoding data types:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shorthand syntax&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Q: quantitative:  &amp;lsquo;a continuous real-valued quantity&amp;rsquo;&lt;/li&gt;&#xA;&lt;li&gt;Discrete/categorical:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;O: ordinal (=sortable)&lt;/li&gt;&#xA;&lt;li&gt;N: nominal (=not sortable)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;T: temporal, G: geojson&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Faceted charts (=multiple side-by-side):&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/compound_charts.html#facet-chart&#34;&gt;Layered &amp;amp; Multi-View Charts — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Simple:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;.encode(x=..,y=..,column=xxx,row=yyy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Sorting&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://vega.github.io/vega-lite/docs/sort.html#sort-field&#34;&gt;Sorting | Vega-Lite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://stackoverflow.com/questions/61495156/rendering-multiple-altair-charts-in-a-single-cell-of-a-jupyter-notebook&#34;&gt;Rendering multiple altair charts in a single cell of a jupyter notebook&lt;/a&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;graph[&lt;span style=&#34;color:#f99b15&#34;&gt;0&lt;/span&gt;]&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;display()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;graph[&lt;span style=&#34;color:#f99b15&#34;&gt;1&lt;/span&gt;]&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;display()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;Legends&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disable: &lt;code&gt;alt.Color().legend(None)&lt;/code&gt;   (! not inside Color()!)&lt;/li&gt;&#xA;&lt;li&gt;Multiple legends&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.geeksforgeeks.org/data-visualization/displaying-two-different-legends-in-hconcat-chart-using-altair/&#34;&gt;Displaying Two Different Legends in hconcat Chart Using Altair - GeeksforGeeks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/scale_resolve.html&#34;&gt;Scale &amp;amp; Guide Resolution — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e7e9db;background-color:#2f1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;encode(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;X(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;variable&amp;#34;&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;Y(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;count()&amp;#34;&lt;/span&gt;),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;Color(&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;value:N&amp;#34;&lt;/span&gt;, legend&lt;span style=&#34;color:#5bc4bf&#34;&gt;=&lt;/span&gt;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;Legend(title&lt;span style=&#34;color:#5bc4bf&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;x&amp;#34;&lt;/span&gt;)),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&lt;span style=&#34;color:#776e71&#34;&gt;# TIL &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;Scale(scheme&lt;span style=&#34;color:#5bc4bf&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#39;blues&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#776e71&#34;&gt;# make colors different too&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#776e71&#34;&gt;#...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;alt&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;vconcat(&lt;span style=&#34;color:#5bc4bf&#34;&gt;*&lt;/span&gt;charts)&lt;span style=&#34;color:#5bc4bf&#34;&gt;.&lt;/span&gt;resolve_scale(color&lt;span style=&#34;color:#5bc4bf&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#48b685&#34;&gt;&amp;#34;independent&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;API: &lt;a href=&#34;https://altair-viz.github.io/user_guide/generated/core/altair.Legend.html&#34;&gt;altair.Legend&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;New lines to labels&#xA;&lt;ul&gt;&#xA;&lt;li&gt;passing a list of strings instead of string makes them newlines[^&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;]&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;labelExpr=&amp;quot;replace(datum.label,&#39;_&#39;,&#39;\\n&#39;)&amp;quot;&lt;/code&gt; doesn&amp;rsquo;t seem to work for newlines&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/customization.html#adjusting-axis-labels&#34;&gt;Customizing Visualizations — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;takes us to &lt;a href=&#34;https://d3js.org/d3-format&#34;&gt;d3-format | D3 by Observable&lt;/a&gt; for formatting a la python, &lt;code&gt;:.2f&lt;/code&gt;  only for numbers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;more on this: &lt;a href=&#34;https://vega.github.io/vega-lite/docs/parameter.html#expr&#34;&gt;Dynamic Behaviors with Parameters | Vega-Lite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;composing&#34;&gt;Composing&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/marks/rule.html&#34;&gt;Rule — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;draw lines and ranges and candlesticks with y2/x2&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://altair-viz.github.io/gallery/line_chart_with_datum.html&#34;&gt;Line Chart with Datum — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt; to highlight values&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;references&#34;&gt;References&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Colors are valid CSS color names: [&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/named-color&#34;&gt;&lt;named-color&gt; CSS type - CSS | MDN&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://altair-viz.github.io/user_guide/encodings/index.html#encoding-data-types&#34;&gt;Encodings — Vega-Altair 6.3.0.post4+gb2ca919d documentation&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/vega/altair/issues/2376&#34;&gt;Line break or word wrap for labels in axis · Issue #2376 · vega/altair&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
