Description
Hello - thanks again for your great work to implement ggplot2
functionality in Python!
My question is about an enhancement to the legend created when drawing a geom_point()
plot with a size
mapped to a continuous variable. Here's a minimal demo example:
import polars as pl
import plotnine as p9
import numpy as np
rng = np.random.default_rng(12345)
n=150
df = pl.DataFrame({
"x": 10 * rng.random(size=n),
"y": 5 * rng.random(size=n),
"var1": 100 * rng.random(size=n),
})
(
p9.ggplot(df, p9.aes("x", "y", size="var1"))
+ p9.geom_point(color='black', fill='white')
)
which creates the following plot with point sizes mapped to var1
.
All good so far, but I'd like to show the legend entries as nested circles, rather than the conventional stacked style as shown on the plot. The nested style is not only aesthetically pleasing but makes the relative sizes easier to compare. I have seen this style of legend used in The Economist and The Wall Street Journal as well as other publications. (see example below)
Not sure if ggplot2
offers this out of the box, but think this would be a nice feature!
Thanks