Legend display for bubble sizes in geom_point

未关闭
#943 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

未提及任何文件、测试或代码入口点。首先复现所提供的 plotnine geom_point 示例,将大小映射到 var1,然后研究其连续大小图例的配置方式;当图例能够显示嵌套圆形,同时保留映射的大小标签时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Extensions

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.

Image

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)

Image

Not sure if ggplot2 offers this out of the box, but think this would be a nice feature!

Thanks

主要语言
Python
星标
4.8k
派生
269
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

has2k1/plotnine 的其他 Issue

查看 has2k1/plotnine 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。