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

negative polar values · Issue #2133 · matplotlib/matplotlib · GitHub

Repository navigation

negative polar values #2133

Closed
Closed

Description

A issue raised in this (http://stackoverflow.com/questions/17154006/pyplot-polar-scatter-plot-color-for-sign) SO question, the way that polar plots handles negative numbers changed between 1.2.0 and 1.2.1.

If this is an un-intentional change, should probably be fixed before 1.3.0.

maybe related to #1603

Activity

  1. joferkington commented on Jun 18, 2013

    Contributor

    Just as a simple example of the change:

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='polar')
    
    theta = [0, np.pi/2]
    ax.plot(theta, [0.5, 0.5], 'ro')
    ax.plot(theta, [-0.5, -0.5], 'go')
    
    plt.show()

    With v1.2.0 and earlier, the above example results in:

    With 1.2.1 (and the current git head):

    As a simple test for the behavior:

    from matplotlib.projections import PolarAxes
    import numpy as np
    
    trans = PolarAxes.PolarTransform()
    result = trans.transform_point([0, -1])
    assert not all(np.isnan(result))

    As @tacaswell mentioned, this is a result of #1603. That bugfix would seem to indicate that "reflecting" negative radius values to the opposite direction was never supposed to be the intended behavior. However, it's how polar plots have worked in matplotlib for quite some time.

    Which one is the "correct" behavior?

  2. dmcdougall commented on Jul 1, 2013

    Member

    I've been thinking about this for a few days now, and I have come to the conclusion that v1.2.1 fixed a long-standing bug with how negative radii were handled. Any time I've used polar coordinates the radius was always positive and if you wanted points in the opposite direction you must change the theta variable. That said, there's certainly an argument to be made for the flexibility of being able to reflect points easily by flipping a sign.

    From Wikipedia:

    Where a unique representation is needed for any point, it is usual to limit r to
    non-negative numbers (r ≥ 0) and φ to the interval [0, 360°) or (−180°, 180°] (in radians,
    [0, 2π) or (−π, π]).
    

    For that reason, I think I'm going to close this. If anybody would like to reopen to continue discussion, please feel free to do so.

  3. Shooter23 commented on Jan 24, 2019

    https://en.wikipedia.org/wiki/Polar_coordinate_system

    Under "Uniqueness of polar coordinates":

    "Similarly, any polar coordinate is identical to the coordinate with the negative radial component and the opposite direction (adding 180° to the polar angle)."

    This suggests that the original behavior was correct.

  4. timhoffm commented on Jan 25, 2019

    Member

    That is true if you really want to plot polar coordinates (which also implies you always have to start from 0 radius in the center). Even though the projection is called 'polar', this radial plot has a broader scope in which negative values may actually exist at certain angles and are not equivalent to the absolute value rotated by 180 degrees.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL