position_dodge not working with categorical y and continous x variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- data-visualization
Research direction
Start by running the two plotnine examples from the issue with the dots dataset, comparing position_dodge for categorical x versus categorical y. Trace the position_dodge and geom_point entry points to find why continuous x with categorical y is not separated, then add or update a regression test showing the expected dodged output.
Written by the indexing model from the issue text.
Description
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))
)
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))
)
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))
)
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
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 269
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from has2k1/plotnine
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Feature request: add rotation_mode param to geom_textPossibly taken A pull request linked to this issue is open or already merged. OpenFeature
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
position_dodge2() leaves nested rectangles overlappingPossibly taken @MahnoorAhmed999 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Enhancement
Difficulty 3/5 Half a day Newbie friendliness 55/100
-
Enhancement
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
plone/plone.observability#114 ·
Maintainers usually reply within 1 day
-
area:docs type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jejjohnson/gauss_flows#246 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openvax/varcode#824 · 1 comment ·
Maintainers usually reply within 1 day
-
netbox status: needs triage type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
netbox-community/netbox#23868 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
emeryberger/CSrankings#15757 ·
Maintainers usually reply within 9 days