position_dodge not working with categorical y and continous x variables

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

首先使用 dots 数据集运行 issue 中的两个 plotnine 示例,比较针对分类 x 和分类 y 的 position_dodge。跟踪 position_dodge 和 geom_point 的入口点,找出连续 x 与分类 y 未被分离的原因,然后添加或更新一个回归测试,以展示预期的 dodge 输出。

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

描述

Orientation Aware Geoms

I illustrate the problem with the dots dataset:

import pandas as pd
from plotnine import *

dots = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/dots.csv')

Now, I plot with categorical x and continuous y variable:

(
    ggplot(dots, aes(y='coherence', x='align', color='choice'))
    + geom_point(position = position_dodge(width=0.8))
)

image

This worked fine. Now, I swap the x- and y-axis:

(
    ggplot(dots, aes(x='coherence', y='align', color='choice'))
    + geom_point(position = position_dodge(width=0.8))
)

image
Now, position_dodge did not work anymore.

ggplot2 gives me what I would expect (I execute the following in a Jupyter notebook)

%load_ext rpy2.ipython
%%R -i dots
library(ggplot2)
(
    ggplot(dots, aes(x=coherence, y=align, color=choice))
    + geom_point(position = position_dodge(width=0.8))
)

image

Software versions:

import session_info
session_info.show()
-----
pandas              2.2.2
plotnine            0.13.6
session_info        1.0.0
-----

Click to view modules imported as dependencies

-----
IPython             8.26.0
jupyter_client      8.6.2
jupyter_core        5.7.2
-----
Python 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0]
Linux-3.10.0-1062.18.1.el7.x86_64-x86_64-with-glibc2.17
-----
Session information updated at 2024-07-15 16:29
主要语言
Python
星标
4.8k
派生
260
平均合并
2 天 12 小时
30 天内合并 PR
4

环境准备

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

从这里开始

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

has2k1/plotnine 的其他 Issue

查看 has2k1/plotnine 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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