Skip to content

adding check_xytext for NaN values #30381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AndrGutierrez
Copy link
Contributor

PR summary

Closes #29516 , I have a few things to address here, this PR fixes errors for this type of case:

import matplotlib.pyplot as plt, numpy as np

ax = plt.figure().add_subplot()
ax.annotate('', (0, 0), (np.nan, np.nan), arrowprops={})

plt.show()

It checks that the coordinates for xytext are a finite number, and if it isn't, the text and the arrow are not drawn, same behaviour as check_xy.

I wasn't able to reproduce the first error in the thread in a similar environment, and for this other piece of code:

import matplotlib.pyplot as plt

ax = plt.figure().add_subplot(projection="polar")
ax.set_ylim(.25, 1.25)
ax.annotate('', (0, .5), (0, 0), arrowprops={})

plt.show()

the error seems to be related to set_ylim, if you remove that, it works. Also, if you change the y coordinate for xy to be less than ylim's bottom, for example:

import matplotlib.pyplot as plt

ax = plt.figure().add_subplot(projection="polar")
ax.set_ylim(.25, 1.25)
ax.annotate('', (0, .2499), (0, 0), arrowprops={})

plt.show()

it seems to work for anything < ylim's bottom (.25 in this case), so I guess the error appears when the text is supposed to be visible, this behaviour is weird and the easiest solution I can think of is just to not apply/allow ylim because it doesn't do anything in polar coordinates, but I don't have enough context to know if that's a good idea or even possible so I would like feedback on that 🙂.

PR checklist

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

Successfully merging this pull request may close these issues.

[Bug]: Cannot draw arrow from polar plot origin after setting rticks
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy