<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Marek</title>
    <description>The latest articles on DEV Community by Marek (@marepilc).</description>
    <link>https://dev.to/marepilc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3982399%2Fb5a63bf5-ef71-47e8-98f0-26412f10b074.webp</url>
      <title>DEV Community: Marek</title>
      <link>https://dev.to/marepilc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marepilc"/>
    <language>en</language>
    <item>
      <title>Build a Revenue and Stock Price Combo Chart with Python</title>
      <dc:creator>Marek</dc:creator>
      <pubDate>Sun, 14 Jun 2026 16:12:16 +0000</pubDate>
      <link>https://dev.to/marepilc/build-a-revenue-and-stock-price-combo-chart-with-python-4ne4</link>
      <guid>https://dev.to/marepilc/build-a-revenue-and-stock-price-combo-chart-with-python-4ne4</guid>
      <description>&lt;p&gt;Financial charts often combine metrics that live on completely different scales.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
company revenue measured in billions of dollars,&lt;br&gt;
stock prices measured in tens or hundreds of dollars.&lt;/p&gt;

&lt;p&gt;I wanted to recreate the infographic style seen on Visual Capitalist using pure Python and SVG.&lt;/p&gt;

&lt;p&gt;The chart combines:&lt;/p&gt;

&lt;p&gt;annual revenue as bars,&lt;br&gt;
monthly stock prices as a line,&lt;br&gt;
a secondary axis,&lt;br&gt;
a clipped gradient area inside the revenue columns.&lt;/p&gt;

&lt;p&gt;One of the most interesting parts is the clipping effect.&lt;/p&gt;

&lt;p&gt;The stock-price area spans the entire chart, but SVG clipping reveals it only inside the revenue bars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;stock_layer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;G&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;area_generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stock_points&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;url(#area-gradient)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;clip_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;url(#revenue-clip)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a visual connection between the two datasets without sacrificing readability.&lt;/p&gt;

&lt;p&gt;The chart is generated entirely as SVG using pyDreamplet, which means:&lt;/p&gt;

&lt;p&gt;resolution independent output,&lt;br&gt;
easy customization,&lt;br&gt;
structured graphics instead of pixels,&lt;br&gt;
perfect for reports, dashboards, and infographics.&lt;/p&gt;

&lt;p&gt;A few design decisions helped keep the chart readable:&lt;/p&gt;

&lt;p&gt;bars and lines use different visual encodings,&lt;br&gt;
each series has its own color,&lt;br&gt;
only one axis draws gridlines,&lt;br&gt;
labels stay outside the plotting area,&lt;br&gt;
decorative elements never compete with the data.&lt;/p&gt;

&lt;p&gt;The complete tutorial walks through:&lt;/p&gt;

&lt;p&gt;loading the data,&lt;br&gt;
building scales,&lt;br&gt;
generating bars,&lt;br&gt;
drawing the stock-price curve,&lt;br&gt;
creating clipping paths,&lt;br&gt;
embedding SVG icons,&lt;br&gt;
exporting the final graphic.&lt;/p&gt;

&lt;p&gt;👉 Full step-by-step tutorial:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://py.dreamplet.com/tutorials/combo-chart" rel="noopener noreferrer"&gt;https://py.dreamplet.com/tutorials/combo-chart&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 Source code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/marepilc/pydreamplet-showcase/tree/master/scripts/combo_chart" rel="noopener noreferrer"&gt;https://github.com/marepilc/pydreamplet-showcase/tree/master/scripts/combo_chart&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>data</category>
    </item>
  </channel>
</rss>
