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

polar plot incorrectly handles units of degrees/radians · Issue #6144 · matplotlib/matplotlib · GitHub

Repository navigation

polar plot incorrectly handles units of degrees/radians #6144

Open

Description

Setup

matplotlib.__version__= 1.5.1 (installed as part of anaconda distribution)
Python 3.4.4
OS X

Issue

Code from examples/units/radian_demo.py with minor modifications:

import numpy as np
from basic_units import radians, degrees, cos
from matplotlib.pyplot import figure, show

x = [val*radians for val in np.arange(0, 15, 0.01)]

fig = figure()

ax = fig.add_subplot(121, projection='polar')
line1, = ax.plot(x, np.array(cos(x))+1, xunits=radians)

ax = fig.add_subplot(122, projection='polar')
line2, = ax.plot(x, np.array(cos(x))+1, xunits=degrees)

show()

Notes

Note that the plot on the left is correct, but the angular tick labels aren't incrementing correctly. I can't tell if this is an issue with the basic_units.py example implementation or the units interface.

If it seems like a straightforward fix, I'd be happy to take a look at it: the units interface is really slick and it would be great to get this working with polar coordinates too.

Activity

  1. added this to the milestone on Mar 11, 2016
  2. QuLogic commented on Mar 11, 2016

    Member

    Probably related to #4905.

  3. modified the milestones: , on Oct 3, 2017
  4. github-actions commented on Mar 23, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. ksunden commented on Mar 23, 2023

    Member

    This behavior does persist, but I think it is purely a limitation of basic units, not the actual polar axes (not fully sure how...)

    When I convert the example code to use either pint or unyt, the expected graph is produced for both radians and degrees as the xunits.

    Using pint (use unit registry, np.cos instead of imported cos):

    import numpy as np
    import pint
    from matplotlib.pyplot import figure, show
    ureg = pint.UnitRegistry()
    radians = ureg["rad"]
    degrees = ureg["deg"]
    
    x = [val*radians for val in np.arange(0, 15, 0.01)]
    
    fig = figure()
    
    ax = fig.add_subplot(121, projection='polar')
    line1, = ax.plot(x, np.array(np.cos(x))+1, xunits=radians)
    
    ax = fig.add_subplot(122, projection='polar')
    line2, = ax.plot(x, np.array(np.cos(x))+1, xunits=degrees)
    
    show()

    So, given that basic units is quite stripped down and only really intended for narrow usage in examples, I'm inclined to lean towards just closing, though I could see figuring out why it is broken here (and other unit libraries are not).

    Edit: just realized that the ticks are in degrees in both plots, so perhaps still something to look at there... was focused on the shape and the axis labels of the degrees plot, forgot to check the radians one as closely. Behavior in that regard is identical for both unyt and pint

  6. ksunden commented on Mar 23, 2023

    Member

    I will note that the basic_units.py version is slightly changed.

    In addition to simple style changes, the ticks for the degrees plot are shown at integers (at the radians, to be precise) for 0-6 (with the degree sign, still) rather than evenly spaced, repeating 3 as it was originally.

  7. github-actions commented on Mar 25, 2024

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  8. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Mar 25, 2024
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL