GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix `clabel` manual argument not accepting unit-typed coordinates by aman-coder03 · Pull Request #31278 · matplotlib/matplotlib

Conversation

@aman-coder03

@aman-coder03 aman-coder03 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

PR summary

when unit typed coordinates(e.g datetime) are passed to the manual argument of clabel...they were passed directly to transform.transform() without unit conversion, causing a TypeError because the transform expects float64 but received Python objects

fixed by calling self.axes.convert_xunits(x) and self.axes.convert_yunits(y) in add_label_near() before applying the transform. This is the same pattern already used elsewhere in _base.py and is a no-op when nounit converter is registered, so non-unit axes are unaffected

AI Disclosure

PR checklist

  • "closes [Bug]: clabel manual argument does not accept units #27525 " is in the body of the PR description to link the related issue
  • new and changed code is tested
  • Plotting related features are demonstrated in an example
  • New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rwtarpit and Chirag3841 reacted with hooray emoji
All reactions
  • 🎉 2 reactions
@aman-coder03
Fix clabel manual argument not accepting units
6332e6c
@github-actions github-actions Bot added the topic: contour label Mar 11, 2026
@github-actions

github-actions Bot commented Mar 11, 2026

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the first-contribution label Mar 11, 2026
@github-project-automation github-project-automation Bot added this to First Time Contributors Mar 11, 2026
@aman-coder03 aman-coder03 mentioned this pull request Mar 11, 2026
[Bug]: clabel manual argument does not accept units #27525
Closed
@rcomer

rcomer commented Mar 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Hi @aman-coder03 thank you for your interest in contributing to Matplotlib! Please can you run the example from the issue with your branch, and post the image that it now produces.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer rcomer added the status: needs confirmation label Mar 11, 2026
@aman-coder03

aman-coder03 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

sure! here is the output produced by the example from the issue with my fix applied
image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer rcomer removed the status: needs confirmation label Mar 11, 2026
@aman-coder03

aman-coder03 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

failing tests are unrelated to this fix test_webagg is a known flaky timeout issue and test_upsample_interpolation_stage is a subprocess resource warning... all other 9921 tests pass

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer

rcomer commented Mar 11, 2026

Copy link
Copy Markdown
Member

Thanks for posting the image. I agree that looks correct. Please can you modify this test so it covers the case you are fixing.

matplotlib/lib/matplotlib/tests/test_datetime.py

Lines 262 to 266 in 51a1ab6

@pytest.mark.xfail(reason="Test for clabel not written yet")
@mpl.style.context("default")
def test_clabel(self):
fig, ax = plt.subplots()
ax.clabel(...)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aman-coder03
add test for clabel with datetime units
3a77348
@aman-coder03

aman-coder03 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@rcomer i have added the test now!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rcomer

rcomer commented Mar 11, 2026

Copy link
Copy Markdown
Member

Thanks for adding the test. Is there any way it could be simplified, but still fail without your change?

aman-coder03 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aman-coder03

aman-coder03 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

yes @rcomer working on simplifying it, will push a commit shortly

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aman-coder03
simplify test_clabel
c088b57
@melissawm melissawm moved this to Needs review in First Time Contributors Mar 11, 2026
rcomer
rcomer approved these changes Mar 11, 2026
View reviewed changes

@rcomer rcomer left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks @aman-coder03. This seems right to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aman-coder03 reacted with hooray emoji
All reactions
  • 🎉 1 reaction
story645
story645 reviewed Mar 11, 2026
View reviewed changes
Comment thread lib/matplotlib/contour.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/matplotlib/tests/test_datetime.py Outdated
fig, ax = plt.subplots()
ax.clabel(...)
CS = ax.contour(X, Y, Z)
ax.clabel(CS, manual=[(x[0], dates[0])])

@story645 story645 Mar 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you test that the label is set to the expected value?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@aman-coder03 aman-coder03 Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

sure i can add an assertion on the label value, what would be the best way to check it, assert on the text string or the position?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@story645 story645 Mar 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Both?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aman-coder03 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@aman-coder03 aman-coder03 Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aman-coder03
Add assertions to test_clabel
fd27483
story645
story645 approved these changes Mar 11, 2026
View reviewed changes
@story645 story645 modified the milestones: v3.11.0, v3.10.9 Mar 11, 2026
@story645
story645 merged commit a01f57d into matplotlib:main Mar 11, 2026
32 of 36 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-project-automation github-project-automation Bot moved this from Needs review to Merged in First Time Contributors Mar 11, 2026
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 11, 2026
@aman-coder03 @meeseeksmachine
Backport PR matplotlib#31278: Fix clabel manual argument not accept…
ef19bdc
…ing unit-typed coordinates
@meeseeksmachine meeseeksmachine mentioned this pull request Mar 11, 2026
Backport PR #31278 on branch v3.10.x (Fix clabel manual argument not accepting unit-typed coordinates) #31280
Merged
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
@andreas16700
Run a01f57d: Fix clabel manual argument not accepting unit-typed co…
4726c51
…ordinates (matplotlib#31278)
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
@andreas16700
Run a01f57d: Fix clabel manual argument not accepting unit-typed co…
da12b31
…ordinates (matplotlib#31278)
ksunden added a commit that referenced this pull request Apr 21, 2026
@ksunden
Merge pull request #31280 from meeseeksmachine/auto-backport-of-pr-31…
851f769
…278-on-v3.10.x

Backport PR #31278 on branch v3.10.x (Fix `clabel` manual argument not accepting unit-typed coordinates)
This was referenced Apr 21, 2026
Backport PR #31282 on branch v3.10.x (SEC: Block shell escapes in latex and ps commands) #31542
Closed
Backport PR #31248 on branch v3.10.x (SEC: Remove eval() from validate_cycler) #31543
Closed
merge up v3.10.9 #31560
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@story645 story645 story645 approved these changes
@rcomer rcomer rcomer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

first-contribution topic: contour

Projects

First Time Contributors
Status: Merged

Milestone

v3.10.9

Development

Successfully merging this pull request may close these issues.

[Bug]: clabel manual argument does not accept units

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@aman-coder03 @rcomer @story645
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.