FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Crash when creating polar plot with log scale on radial axis · Issue #1847 · matplotlib/matplotlib · GitHub

Repository navigation

Crash when creating polar plot with log scale on radial axis #1847

Closed

Description

matplotlib will crash when a log scale is used for the radial axis of a polar plot, unless very specific commands are used to create the plot. The following code will cause a crash:

import numpy as np
import matplotlib.pyplot as plt

theta = np.arange(0.0, 2 * np.pi, 0.05)
r = np.arange(0.1, 100.0, 100.0 / len(theta))

plt.figure()
ax = plt.subplot(111, polar=True, projection='polar')
ax.set_rlim((0.1, 100.0))
ax.set_rscale('log')
plt.polar(theta, r)

plt.savefig('test.pdf', format='pdf')
plt.show()

However, if ax.set_rlim((0.1, 100.0)) is changed to ax.set_rlim((0., 100.0)) the plot is created and there is no error or warning. The plot will also crash if the set_rlim method is not called before set_rscale. Using set_ylim or set_yscale results in the same behavior.

Note that this issue is not specific to a particular backend, as it occurs when saving the figure as a PDF or displaying it in a window with gtkagg.

Other users have this problem; see http://stackoverflow.com/questions/14919407/how-to-use-log-scale-on-polar-axis-in-matplotlib

Activity

  1. amill676 commented on Dec 15, 2013

    Any progress on this? This is pretty frustrating, as the polar log plots seem to be useless.

  2. efiring commented on Dec 15, 2013

    Member

    Your example does not crash for me, running 1.4.x. What versions have you tried?

  3. amill676 commented on Dec 15, 2013

    I was able to get the code running, but the problem I was running into was discussed in one of the followups of that stack overflow discussion. The log polar plots were plotting 'negative' radii. However, I updated to the latest matplotlib, and it doesn't appear to be doing this anymore, although how set_rlim/set_rmax/set_rmin exactly affects the scaling of the plot seems kind of convoluted. However, with enough toying I can get the results I want.

  4. amill676 commented on Dec 15, 2013

    In fact, it seems that set_rlim(0,1) will result in limits (u, 1), where u > 0 (.01 in my case), but set_rmin(0), set_rmax(1) will give the intended behavior.

  5. efiring commented on Dec 15, 2013

    Member

    With a log scale on the radial axis, a lower limit of zero makes no sense at all; what is the intended behavior to which you refer?

  6. amill676 commented on Dec 15, 2013

    From what I've seen, setting the lower limit to 0 and the maximum limit to some value > 0 will give a plot that goes from the lowest data value given to the maximum limit supplied. But when setting rmin to something less than the lowest data value given, the bounds are no longer obeyed. So in that sense, I guess by a lower limit of 0 I just meant fitting the bound to the lower range of the data. Which has seemed hard to achieve otherwise. Unless I'm missing something

  7. added this to the v1.4.0 milestone on Mar 4, 2014
  8. tacaswell commented on Jun 29, 2014

    Member

    Reading through this again, it looks like the original problem has been (mysteriously?) fixed. From reading this + the SO thread I am having trouble sorting out exactly what is wrong so I am closing this issue.

    @amill676 @cfinch If you are still having problems please open a new issue.

  9. cfinch commented on Jul 24, 2014

    Author

    The issue is resolved for me.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL