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

Skip to content

Fix rectangular patches to be properly transformed on polar axes #8539

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

Merged
merged 9 commits into from Apr 28, 2017
Merged

Fix rectangular patches to be properly transformed on polar axes #8539

merged 9 commits into from Apr 28, 2017

Conversation

ghost
Copy link

@ghost ghost commented Apr 26, 2017

PR Summary

Rectangle patch not transformed correctly in polar plot #8521. The bug fix tries to specify the number of _interpolation_steps for Path._unit_rectangle in the _AxesBase.add_patch() function. It appears that 'polar' transforms require more than the default _interpolation_steps == 1.

More test cases can be generated upon request

#8521

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/whats_new.rst if major new feature
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@phobson phobson changed the title Tuan Fix rectangular patches to be properly transformed on polar axes Apr 26, 2017
@phobson
Copy link
Member

phobson commented Apr 26, 2017

This PR looks good. After a little more review happens, would you mind squashing these commits down to a single commit? If not we can take care of it when it's merged.

@phobson phobson added this to the 2.0.1 (next bug fix release) milestone Apr 26, 2017
@phobson phobson changed the title Fix rectangular patches to be properly transformed on polar axes [MRG+1] Fix rectangular patches to be properly transformed on polar axes Apr 26, 2017
Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Overall this looks really good, thanks for the PR!

The test needs a couple of changes, and the test should also be moved to an existing test file (probably lib/matplotlib/tests/test_patches.py)


@image_comparison(baseline_images=['polar_proj'], extensions=['png'])
def test_adding_rectangle_patch():
fig = plt.figure(figsize=(640/80, 640/80), dpi=80)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need to specify the figsize or dpi, just plt.figure() should be fine.

# add quadrant as example
ax.add_patch(
patches.Rectangle(
(0, 1), width=math.pi * 0.5, height=0.5
Copy link
Member

Choose a reason for hiding this comment

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

To be consistent with the rest of the tests, this should use numpy and be np.pi

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the input. Will fix this as soon as I get home today from work.

@QuLogic
Copy link
Member

QuLogic commented Apr 27, 2017

I'm not sure we need a separate file for this either; it should be able to fit in test_axes.py, I think.

@QuLogic
Copy link
Member

QuLogic commented Apr 27, 2017

Oh, I see @dstansby suggested test_patches.py, which seems good too.

@ghost
Copy link
Author

ghost commented Apr 27, 2017

@phobson Could you please kindly give me some pointers on how to squash the commits together? I don't normally use git, and have not found anything useful on the internet :)

@phobson
Copy link
Member

phobson commented Apr 27, 2017

@dstansby can you take another look at this?

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me, thanks for the PR!

@dstansby dstansby changed the title [MRG+1] Fix rectangular patches to be properly transformed on polar axes Fix rectangular patches to be properly transformed on polar axes Apr 28, 2017
@dstansby dstansby merged commit 3e2e31e into matplotlib:master Apr 28, 2017
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Oct 2, 2017
This reverts commit 3e2e31e, reversing
changes made to 8149536.

This has some un-intended consequences (see matplotlib#9261).  This exposes a
bigger issue about drawing on to non-linear axes which is if we
transform only the vertices or the full paths.  Which the user wants
is dependent on context so we need to expose this at the user API in a
nice way, but is a bigger change than we can accommodate for 2.1.

Reverting this change to return to the (slightly) broken state which
has been the satus-quo 7 years.
tacaswell added a commit that referenced this pull request Oct 2, 2017
Revert "Merge pull request #8539 from Tuan333/tuan"
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 this pull request may close these issues.

3 participants