<p dir="auto">I grew tired of having to convert my units just for the sake of specifying the figure size. I'd like to specify the figure size directly in a metric unit, nominally centimeters (or millimeters, no difference). In most EU countries metric is the norm. I only have to deal with inches when looking at monitor sizes, printing, and matplotlib :(</p>
<p dir="auto">I've found at least two issues about this: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="7539084" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/1369" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/1369/hovercard" href="https://github.com/matplotlib/matplotlib/issues/1369">#1369</a> and the more generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="260354239" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/9226" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/9226/hovercard" href="https://github.com/matplotlib/matplotlib/issues/9226">#9226</a>.</p>
<p dir="auto">Of course, having support for generic unit specifiers would be nice, but I'm not entirely satisfied by the extra complexity of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="260354239" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/9226" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/9226/hovercard" href="https://github.com/matplotlib/matplotlib/issues/9226">#9226</a>. I'm also thorn about (size, unit) tuples, because I don't ever think I'm going to specify the figure size in AU, or picometers. Cm is regularly used for anything that fits paper.</p>
<p dir="auto">I see two cases where inches are specified in the rc:</p>
<ul dir="auto">
<li>figure.figsize</li>
<li>savefig.pad_inches</li>
</ul>
<p dir="auto">In the api, there is the figsize kwarg, I guess a pad_inches kwarg, and the set_size_inches method.</p>
<p dir="auto">What abound the KISS approach: add a figsize_cm kwarg, pad_cm, and the set_size_cm method, and the two respective rcParams? Fully backward compatible, and allows metric countries to get by easily.</p>
<p dir="auto">I could easily contribute such a patch.</p>
<h3 dir="auto">Problem</h3>
<p dir="auto">I've noticed that matplotlib currently doesn't support saving images in webp format, which I later confirmed by looking into supported file formats in <a href="https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backend_bases.py">backend_bases.py</a> file.</p>
<p dir="auto">Saving images in webp would definitely be useful for users who want to upload the graphs they generate in matplotlib to the web. Compression to webp helps significantly reduce the image size, without losing quality. More information about webp can be found <a href="https://developers.google.com/speed/webp" rel="nofollow">here</a>.</p>
<h3 dir="auto">Proposed solution</h3>
<p dir="auto">Would it be possible to add webp as a supported image saving format? It seems that <code class="notranslate">Pillow</code> package is automatically installed as a dependency when installing <code class="notranslate">matplotlib</code>. <code class="notranslate">Pillow</code> makes it relatively easy to convert an image to webp using the <code class="notranslate">save()</code> method. More detailed information can be found in the <a href="https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html?highlight=webp#webp" rel="nofollow">documentation</a></p>
<h3 dir="auto">Additional context and prior art</h3>
<p dir="auto"><em>No response</em></p>