Kazu's Log

Kazuyoshi Kato is a Japanese software developer in Seattle, Washington. He is interested in programming languages, data visualization and prototyping.

Just a small tip, which I didn’t know in the beginning.

plotnine’s save method takes dpi as a parameter.

from plotnine import * # import ggplot(), aes(), ...
g = ggplot(...)
g.save('plot.png', width = 10, height = 10, dpi = 100)
g.save('plot-2x.png', width = 10, height = 10, dpi = 200)

Then you can use srcset to specify the images from HTML.

<img alt="..." src=".../companies.png" srcset=".../companies-2x.png 2x"/>

Also during exploration, I occasionally set plotnine.options.figure_size to have relatively large images.

import plotnine
plotnine.options.figure_size = (20, 20)