Thanks to visit codestin.com
Credit goes to github.com

Skip to content

polar plots do not properly handle units #4905

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
wants to merge 3 commits into from

Conversation

jrevans
Copy link

@jrevans jrevans commented Aug 11, 2015

PolarAxes was not properly handling unitized data

This addresses an issue in #4897.

angles = np.asarray(angles, np.float_)
self.set_xticks(angles * (np.pi / 180.0))
else:
# The unit converters are defined to return radians
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly question, where is this documented/implemented?

@tacaswell tacaswell added this to the next point release milestone Aug 11, 2015
self.set_xticks(angles * (np.pi / 180.0))
if isinstance( angles[0], float ):
# If the data is floats it is assumed to be degrees (as per the
# docsting for this method)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring

@QuLogic
Copy link
Member

QuLogic commented Aug 12, 2015

Side note: there's no reason to prefix your commit messages with your initials; that's why you set your author info before committing anything.

@@ -399,6 +399,8 @@ def set_theta_offset(self, offset):
"""
Set the offset for the location of 0 in radians.
"""
# Make sure to strip away units
offset = self.convert_yunits(offset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And x here too.

@tacaswell
Copy link
Member

Can you modify or extend https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tests/test_axes.py#L384 to catch this issue?

Added more test cases to test polar functions.
@jrevans
Copy link
Author

jrevans commented Aug 17, 2015

When moving my fixes over to git, I had accidentally transposed which axis was used for the unit conversion. I have fixed that.

I have also added some more test cases to test for this. I am not sure what the process is for generating the baseline images or even running the test harness anymore. It has changed dramatically from when I first wrote it up so many years ago. What is the process for this now?

@tacaswell
Copy link
Member

See
http://matplotlib.org/devel/testing.html#writing-an-image-comparison-test
for the current directions

On Mon, Aug 17, 2015, 3:54 PM James Evans [email protected] wrote:

When moving my fixes over to git, I had accidentally transposed which axis
was used for the unit conversion. I have fixed that.

I have also added some more test cases to test for this. I am not sure
what the process is for generating the baseline images or even running the
test harness anymore. It has changed dramatically from when I first wrote
it up so many years ago. What is the process for this now?


Reply to this email directly or view it on GitHub
#4905 (comment)
.

@WeatherGod
Copy link
Member

Essentially, just run the test directly (after installing the latest
changess). So, from the root source directory: python lib/matplotlib/tests/test_foobar.py). It'll run and error on the new test,
but it will produce artifacts like
"result_images/test_foobar/this_new_test_image.png". Verify the new
artifacts are right and then copy them over to
"lib/matplotlib/tests/baseline_images/test_foobar/". Rerun the test to make
sure all is well, and then add and commit those images.

On Mon, Aug 17, 2015 at 3:54 PM, James Evans [email protected]
wrote:

When moving my fixes over to git, I had accidentally transposed which axis
was used for the unit conversion. I have fixed that.

I have also added some more test cases to test for this. I am not sure
what the process is for generating the baseline images or even running the
test harness anymore. It has changed dramatically from when I first wrote
it up so many years ago. What is the process for this now?


Reply to this email directly or view it on GitHub
#4905 (comment)
.

@tacaswell
Copy link
Member

ping @jrevans Any update on this?

theta /= math.pi
# \u03b8: lower-case theta
# \u03c0: lower-case pi
# \u00b0: degree symbol
return '\u03b8=%0.3f\u03c0 (%0.3f\u00b0), r=%0.3f' % (theta, theta * 180.0, r)
s = '\u03b8=%0.3f\u03c0 (%0.3f\u00b0), r=%0.3f' % (theta, theta * 180.0, r)
s = s.encode( 'utf-8' )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary and probably indicates a bug somewhere else. Returning unicode from this function is actually what we want. Can you describe which backend/platform you were using when you can across this problem?

@mdboom mdboom self-assigned this Oct 8, 2015
@mdboom
Copy link
Member

mdboom commented Oct 20, 2015

@jrevans: Any progress on addressing the questions above? We may have to punt on this for 1.5.0.

@jrevans jrevans mentioned this pull request Oct 28, 2015
17 tasks
@tacaswell tacaswell modified the milestones: next point release (1.5.0), next bug fix release (2.0.1) Oct 29, 2015
@@ -411,6 +411,107 @@ def test_polar_units():
assert_true(isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter))


def test_polar_format_coord():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a @cleanup decorator so global state does not leak.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@jklymak
Copy link
Member

jklymak commented Oct 6, 2018

I'm not going to close this one because it looks like it was close, but is there any chance it will get some movement? Someone who loves units will need to lead the charge...

@jklymak
Copy link
Member

jklymak commented Oct 15, 2019

Closing this as not likely to be resurrected, but feel free to request a re-open.

@jklymak jklymak closed this Oct 15, 2019
@story645 story645 removed this from the future releases milestone Oct 6, 2022
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.

8 participants