Legend display for bubble sizes in geom_point
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 254
- Avg merge
- 10h 35m
- Merged PRs (30d)
- 9
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or code entry points are mentioned. Start by reproducing the supplied plotnine geom_point example with size mapped to var1, then investigate how its continuous-size legend is configured; done means the legend can display nested circles while preserving the mapped size labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100