Skip to content

Restore pyplot getter semantics for limits and ticks - #470

Open
harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/pyplot-getter-semantics-443
Open

Restore pyplot getter semantics for limits and ticks#470
harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/pyplot-getter-semantics-443

Conversation

@harsh21234i

@harsh21234i harsh21234i commented Aug 6, 2026

Copy link
Copy Markdown

Fixes #443

Summary

  • Restore Matplotlib-style getter and setter behavior for xlim and ylim.
  • Support keyword limit setters and return the resulting limits.
  • Make xticks and yticks getters non-mutating and return locations plus label handles.
  • Return the live Legend handle from pyplot.legend with the correct annotation.
  • Update Axes return types and add reference-semantic regression tests.

Validation

  • Focused issue tests: passed
  • Remaining pyplot tests: 995 passed, 99 skipped
  • Ruff and formatting checks: passed

The full local pyplot invocation also includes pre-existing Windows-environment failures in subprocess import setup, source-file encoding scans, and the optional pandas Matplotlib backend.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Plot limit controls now return current or updated axis limits.
    • Tick controls provide locations and label handles, including non-mutating getters.
    • Legend creation returns a usable legend handle.
  • Bug Fixes

    • Improved consistency and reliability of getter and setter results across plotting controls.

Copy link
Copy Markdown
Author

Implemented and pushed in commit 01dfed28.

The change restores Matplotlib-style getter/setter behavior for xlim/ylim and xticks/yticks, keeps pure getter calls non-mutating, returns resulting limits and tick handles, and annotates pyplot.legend as returning the live Legend handle.

Validation passed for the focused issue tests, 995 remaining pyplot tests (99 skipped), Ruff, and formatting. The full local suite still has unrelated Windows subprocess import/encoding failures and an unavailable optional pandas Matplotlib backend.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Pyplot return-value semantics

Layer / File(s) Summary
Axis limit getters and setters
python/xy/pyplot/__init__.py, python/xy/pyplot/_axes.py, python/xy/pyplot/_plot_types.py, tests/pyplot/test_reference_semantics.py
xlim, ylim, set_xlim, and set_ylim return current or updated bounds. Tests cover getter, setter, positional, and keyword calls.
Axis tick getters and handles
python/xy/pyplot/__init__.py, python/xy/pyplot/_axes.py, python/xy/pyplot/_plot_types.py, tests/pyplot/test_reference_semantics.py
xticks, yticks, set_xticks, and set_yticks return tick locations and label handles. Tests cover non-mutating getters and setter results.
Live legend handle
python/xy/pyplot/__init__.py, tests/pyplot/test_reference_semantics.py
pyplot.legend() returns the legend attached to the current axes. Tests verify the returned handle type and identity.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Issue 443: Covers getter and return-value semantics for limits, ticks, and legends implemented by this change.

Possibly related PRs

  • reflex-dev/xy#336: Modifies the same Axes tick and limit APIs, but addresses log-scale tick and grid behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: restoring pyplot getter semantics for limits and ticks.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

Restores Matplotlib-style getter and return-value semantics for pyplot limits, ticks, and legends.

  • Limit APIs now support non-mutating getters, keyword setters, and resulting-limit returns.
  • Tick getters now return locations and label handles, including correctly routing minor=True to minor ticks.
  • Legend creation returns the live Legend handle, with updated Axes annotations and regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported minor-tick getter now selects minor locations and minor label handles without entering the setter path.

Important Files Changed

Filename Overview
python/xy/pyplot/init.py Adds public getter/setter return semantics and correctly routes minor tick getter requests.
python/xy/pyplot/_axes.py Makes limit and tick setters return their resulting limits or label handles while preserving non-mutating limit getters.
python/xy/pyplot/_plot_types.py Aligns mixin type declarations with the updated Axes return contracts.
tests/pyplot/test_reference_semantics.py Adds regression coverage for limit getters, tick getters, minor tick routing, setter returns, and live legend handles.

Reviews (2): Last reviewed commit: "Fix pyplot minor tick getters" | Re-trigger Greptile

Comment thread python/xy/pyplot/__init__.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread python/xy/pyplot/__init__.py Outdated
Comment thread python/xy/pyplot/__init__.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pyplot] Restore getter and return-value semantics for limits, ticks, and legend

1 participant