Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Simplify some patches path definitions. #24304

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 1 commit into from
Nov 23, 2022
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 29, 2022

  • When a Path ends with a CLOSEPOLY, it is not necessary to put a LINETO to the closing position before it (in fact that can result in an incorrect line join at that position), and the xy position associated with the CLOSEPOLY can just be (0, 0), as it is irrelevant.
  • For defining the codes arrays, for short paths (such as the patch shapes here), one can just use list unpacking for shorter definitions.
  • Rename the _path and _fillable lists in ArrowStyle to plural names.
  • Rely on the default tolerance of
    split_bezier_intersecting_with_closedpath (which is 0.01) rather than
    re-specifying the same magic value everywhere.
  • Remove inapplicable comment re: make_compound_path_from_polys (which
    only applies to polygons all of with the same number of sides, which
    is not the case when clipping to a bbox).

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

lib/matplotlib/patches.py Show resolved Hide resolved
@tacaswell tacaswell added this to the v3.7.0 milestone Nov 1, 2022
arc.codes, arc.codes, [connector, Path.CLOSEPOLY]])
c[len(arc.codes)] = connector
v = np.concatenate([v1, v2, [(0, 0)]])
c = [*arc.codes, connector, *arc.codes[1:], Path.CLOSEPOLY]
Copy link
Member

Choose a reason for hiding this comment

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

In the case of a full anuulus will this result in an extra line connecting the inner and outer rings?

Copy link
Contributor Author

@anntzer anntzer Nov 1, 2022

Choose a reason for hiding this comment

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

No, because for full annuli(?) the connector is MOVETO, which defines a new initial point for a subpath, and CLOSEPOLY closes to that initial point. You can check with e.g.

from pylab import *; w = mpl.patches.Wedge((.5, .5), .3, 0, 360, width=.1, linewidth=5, facecolor="none", edgecolor="k"); figure().add_subplot(aspect=1).add_artist(w)

Copy link
Member

@QuLogic QuLogic Nov 2, 2022

Choose a reason for hiding this comment

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

Shouldn't the outer arc be CLOSEPOLY'd as well, then? I agree the new stuff won't break it, but that seems the semantically correct thing to do (and the existing code didn't do it correctly.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair, but I think that's something that should be fixed at the level of Path.arc(), not here.

- When a Path ends with a CLOSEPOLY, it is not necessary to put a LINETO
  to the closing position before it (in fact that can result in an
  incorrect line join at that position), and the xy position associated
  with the CLOSEPOLY can just be (0, 0), as it is irrelevant.
- For defining the codes arrays, for short paths (such as the patch
  shapes here), one can just use list unpacking for shorter definitions.
- Rename the _path and _fillable lists in ArrowStyle to plural names.
- Rely on the default tolerance of
  split_bezier_intersecting_with_closedpath (which is 0.01) rather than
  re-specifying the same magic value everywhere.
- Remove inapplicable comment re: make_compound_path_from_polys (which
  only applies to polygons all of with the same number of sides, which
  is not the case when clipping to a bbox).
@anntzer
Copy link
Contributor Author

anntzer commented Nov 1, 2022

Also removed an outdated/inapplicable comment while we're at it.

@tacaswell tacaswell merged commit d40feb0 into matplotlib:main Nov 23, 2022
@anntzer anntzer deleted the cp branch November 23, 2022 21:10
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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.