position_dodge2() leaves nested rectangles overlapping

Open
#1,163 0 comments 0 reactions 0 assignees View on GitHub

@MahnoorAhmed999 is already working on this.

Since Dec 3, 2026.

  • #1165 by @MahnoorAhmed999 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

Read find_x_overlaps() in plotnine/positions/position_dodge2.py at the linked lines. Check how it groups intervals when a short rectangle lies between wider overlapping intervals, then run the relevant position dodge tests. Done means the three rectangles no longer overlap after dodging and existing overlap cases still pass.

Written by the indexing model from the issue text.

Description

I plotted three rectangles with x-ranges [0, 10], [5.1, 5.5], and [5.6, 6.0] using geom_rect(position=position_dodge2(padding=0)). All three had the same y-range. After drawing, plotnine placed the wide rectangle at [2.4, 7.4] and left the third rectangle at [5.6, 6.0], entirely inside it. Overlapping rectangles can hide a data series in the resulting chart.

find_x_overlaps() compares each rectangle’s left edge only with the previous rectangle’s right edge. A short rectangle can therefore break the group even when a wider rectangle still spans it. The fix is to group intervals by left edge while tracking the furthest right edge in the current group. Overlap detection

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from has2k1/plotnine

All issues in has2k1/plotnine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.