Skip to content

Using of ax.set_ylim() for polar plot leads to "posx and posy should be finite values" error #11202

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

Closed
ussserrr opened this issue May 8, 2018 · 11 comments · Fixed by #12300
Closed
Milestone

Comments

@ussserrr
Copy link

ussserrr commented May 8, 2018

Bug report

Bug summary

I trying to run my 1-year-old polar plot (made with matplotlib 2.0.0) but with current 2.2.2 version get "posx and posy should be finite values" error. I found out that the error is caused by the ax.set_ylim() method. Such way to manage the axis I've got from this SO question/answer. So this case looks like broken compatibility with older scripts.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure(dpi=120)

ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)

ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)  # anti-clockwise

ax.set_ylim(90, -45)
ax.set_yticks(np.arange(-45, 90+0.1, 15))

plt.show()

Actual outcome

 ⌘  python3 bug_test.py
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
/Users/chufyrev/.local/share/virtualenvs/test-TGICRGwR/lib/python3.6/site-packages/numpy/core/_methods.py:29: RuntimeWarning: invali
d value encountered in reduce
  return umr_minimum(a, axis, None, out, keepdims)
/Users/chufyrev/.local/share/virtualenvs/test-TGICRGwR/lib/python3.6/site-packages/numpy/core/_methods.py:26: RuntimeWarning: invali
d value encountered in reduce
  return umr_maximum(a, axis, None, out, keepdims)
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values
posx and posy should be finite values

Matplotlib version

  • Operating system: macOS High Sierra 10.13.4
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): PyQt5
  • Python version: 3.6.5
  • Other libraries: numpy@1.14.2
@ImportanceOfBeingErnest
Copy link
Member

Are you sure you don't want to do ax.set_ylim(-45, 90) instead of ax.set_ylim(90, -45)?

@ussserrr
Copy link
Author

ussserrr commented May 8, 2018 via email

@ussserrr
Copy link
Author

ussserrr commented May 8, 2018

@ImportanceOfBeingErnest oh, sorry, I tried it right now and it works, actually. Weird bug, thank you :)

@ussserrr ussserrr closed this as completed May 8, 2018
@ImportanceOfBeingErnest
Copy link
Member

I think it would be good not to close this issue just yet. @ussserrr can you reopen?

The point is that even if polar plots require to set the limits in a specific order, there should be a clear error out and not some infinite loop crashing.

@ussserrr ussserrr reopened this May 9, 2018
@ussserrr
Copy link
Author

ussserrr commented May 9, 2018

@ImportanceOfBeingErnest OK.

@pierreolivierbonin
Copy link

also having this issue with a finite looped series of "posx and posy should be finite values" appearing when using ax.text(). The result is fine, so it would be great if we could at least ask Matplotlib to ignore the message as it is taking lots of space when you draw multiple subplots into a single figure.

@jklymak
Copy link
Member

jklymak commented Feb 4, 2021

We think we closed this so can you open a new issue with a standalone reproducible script and information about what version you are using? Thanks!

@pierreolivierbonin
Copy link

Unfortunately, I don't have enough time to do all of this. Just wanted to point it out. I'm sorry if that's unhelpful.

@pierreolivierbonin
Copy link

We think we closed this so can you open a new issue with a standalone reproducible script and information about what version you are using? Thanks!

I have now been able to reproduce the error with less than 20 lines of code. I cannot share the data, but I can share the code. Would that be helpful?

@timhoffm
Copy link
Member

timhoffm commented Feb 4, 2021

It would be good to have a minimal working example. Can you share with dummy-data?

@Gerald-Meyers
Copy link

09192022_NaCl_0-2mmS_3mmD_0D_0-0.01inc_0.5dpm(high res).txt

Example of working code is:

 fig, ax = subplots( 1, 1,
                    figsize=(8, 8),
                    subplot_kw={ 'projection':'polar' },
                    )
xvals, yvals = data
# yscale('log')
# ax.set_theta_zero_location( 'N' )
# ax.set_theta_direction( -1 )
# ax.set_rscale( 'log' )
# ax.set_rlim((0,max(yvals)))

polar( xvals, yvals,
         label=params.get( 'datalabel' ),
         )

savefig( f"{params.get( 'fname' )}_polar" )
close( fig=fig )

Plot functions correctly(ish) but when set to a log-plot the plot malfunctions: the error ""posx and posy should be finite values"" and the entire plot is a blank circle. The 'r' labels are still not correct normally.

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 a pull request may close this issue.

7 participants