Skip to content

Fix categorical pyplot gallery rendering [mpl compatibility] - #253

Closed
sselvakumaran wants to merge 3 commits into
agent/fix-pyplot-autoscale-marginsfrom
agent/categorical-geometry-gallery-compat
Closed

Fix categorical pyplot gallery rendering [mpl compatibility]#253
sselvakumaran wants to merge 3 commits into
agent/fix-pyplot-autoscale-marginsfrom
agent/categorical-geometry-gallery-compat

Conversation

@sselvakumaran

Copy link
Copy Markdown
Contributor

Summary

  • map pyplot categorical coordinates to first-seen ordinal positions while computing view limits, matching the core's category mapping
  • support Matplotlib's per-patch bar(..., label=[...]) legend semantics, including underscore filtering and each patch's resolved color
  • keep bar geometry vectorized and add focused gallery regression coverage for categorical trajectories, legends, and barh widths

Root causes

Pyplot's pre-build autoscale scan discarded string coordinates, so categorical line and scatter plots fell back to a dataless (0, 1) view and clipped every category after the second. Separately, a sequence passed as a bar label was stringified as one container label instead of being attached to the individual bar patches.

Visual comparison

Columns are Matplotlib 3.11, the branch base, and this PR. The first row shows the per-bar legend fix; the second shows all six categorical trajectories restored.

Matplotlib, before, and after categorical gallery comparison

Validation

  • PYTHONPATH=python /Users/srimans/dev/reviz/.venv/bin/python -m pytest -q tests/pyplot/test_categorical_gallery_regressions.py — 5 passed
  • PYTHONPATH=python /Users/srimans/dev/reviz/.venv/bin/python -m pytest -q tests/pyplot — 558 passed, 65 skipped
  • Ruff check and format check pass
  • exact Matplotlib 3.11 gallery sources rendered for bar_colors.py and categorical_variables.py

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 478b4662-32e4-4f50-b0b1-a273f6da2c48

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/categorical-geometry-gallery-compat

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 39.52%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 101 untouched benchmarks
⏩ 1 skipped benchmark1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_build_bar_categorical_pyplot 4.3 ms 7.2 ms -39.52%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing agent/categorical-geometry-gallery-compat (40adc1e) with agent/fix-pyplot-autoscale-margins (3b3c2ab)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@sselvakumaran sselvakumaran changed the title Fix categorical pyplot gallery rendering Fix categorical pyplot gallery rendering [mpl compatibility] Jul 24, 2026
@sselvakumaran

Copy link
Copy Markdown
Contributor Author

maybe a problem solved by another PR - labels should ideally go where there is no lines if possible; like the label here should go in the upper left or lower right of the graph. otherwise this specific fix works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant