| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -9,6 +9,7 @@ | |
| line segments). | ||
| """ | ||
|
|
||
| import itertools | ||
| import math | ||
| from numbers import Number | ||
| import warnings | ||
| Expand Down Expand Up | @@ -163,6 +164,9 @@ def __init__(self, | |
| # list of unbroadcast/scaled linewidths | ||
| self._us_lw = [0] | ||
| self._linewidths = [0] | ||
|
|
||
| self._gapcolor = None # Currently only used by LineCollection. | ||
|
|
||
| # Flags set by _set_mappable_flags: are colors from mapping an array? | ||
| self._face_is_mapped = None | ||
| self._edge_is_mapped = None | ||
| Expand Down Expand Up | @@ -406,6 +410,17 @@ def draw(self, renderer): | |
| gc, paths[0], combined_transform.frozen(), | ||
| mpath.Path(offsets), offset_trf, tuple(facecolors[0])) | ||
| else: | ||
| if self._gapcolor is not None: | ||
| # First draw paths within the gaps. | ||
| ipaths, ilinestyles = self._get_inverse_paths_linestyles() | ||
| renderer.draw_path_collection( | ||
| gc, transform.frozen(), ipaths, | ||
| self.get_transforms(), offsets, offset_trf, | ||
| [mcolors.to_rgba("none")], self._gapcolor, | ||
| self._linewidths, ilinestyles, | ||
| self._antialiaseds, self._urls, | ||
| "screen") | ||
|
|
||
| renderer.draw_path_collection( | ||
| gc, transform.frozen(), paths, | ||
| self.get_transforms(), offsets, offset_trf, | ||
| Expand Down Expand Up | @@ -1459,6 +1474,12 @@ def _get_default_edgecolor(self): | |
| def _get_default_facecolor(self): | ||
| return 'none' | ||
|
|
||
| def set_alpha(self, alpha): | ||
| # docstring inherited | ||
| super().set_alpha(alpha) | ||
| if self._gapcolor is not None: | ||
| self.set_gapcolor(self._original_gapcolor) | ||
|
|
||
| def set_color(self, c): | ||
| """ | ||
| Set the edgecolor(s) of the LineCollection. | ||
| Expand All | @@ -1479,6 +1500,53 @@ def get_color(self): | |
|
|
||
| get_colors = get_color # for compatibility with old versions | ||
|
|
||
| def set_gapcolor(self, gapcolor): | ||
| """ | ||
| Set a color to fill the gaps in the dashed line style. | ||
|
|
||
| .. note:: | ||
|
|
||
| Striped lines are created by drawing two interleaved dashed lines. | ||
| There can be overlaps between those two, which may result in | ||
| artifacts when using transparency. | ||
|
|
||
| This functionality is experimental and may change. | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitysmallest little nit but I'd put only this very last sentence in the note and have everything else as just part of the docstring.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe note here was lifted straight from the equivalent in Line2D.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think it should be changed there too but out of scope so I can put in that PR
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFrom what I remember of #23208, this went through a few iterations: started out with a warning about overlaps that don't look great with transparency. Then the warning was downgraded to a note, and the "experimental" bit added later. Given the amount of previous bikeshedding on this, I would be uncomfortable about changing it without a bit more discussion. That could happen in a follow-up PR, as you say.
Sorry, something went wrong.
story645 reacted with thumbs up emoji
All reactions
|
||
|
|
||
| Parameters | ||
| ---------- | ||
| gapcolor : color or list of colors or None | ||
| The color with which to fill the gaps. If None, the gaps are | ||
| unfilled. | ||
| """ | ||
| self._original_gapcolor = gapcolor | ||
| self._set_gapcolor(gapcolor) | ||
|
|
||
| def _set_gapcolor(self, gapcolor): | ||
| if gapcolor is not None: | ||
| gapcolor = mcolors.to_rgba_array(gapcolor, self._alpha) | ||
| self._gapcolor = gapcolor | ||
| self.stale = True | ||
|
|
||
| def get_gapcolor(self): | ||
| return self._gapcolor | ||
|
|
||
| def _get_inverse_paths_linestyles(self): | ||
| """ | ||
| Returns the path and pattern for the gaps in the non-solid lines. | ||
|
|
||
| This path and pattern is the inverse of the path and pattern used to | ||
| construct the non-solid lines. For solid lines, we set the inverse path | ||
| to nans to prevent drawing an inverse line. | ||
| """ | ||
| path_patterns = [ | ||
| (mpath.Path(np.full((1, 2), np.nan)), ls) | ||
| if ls == (0, None) else | ||
| (path, mlines._get_inverse_dash_pattern(*ls)) | ||
| for (path, ls) in | ||
| zip(self._paths, itertools.cycle(self._linestyles))] | ||
|
|
||
| return zip(*path_patterns) | ||
|
|
||
|
|
||
| class EventCollection(LineCollection): | ||
| """ | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNote that do_single_path_optimization is only True if all the lines are solid
matplotlib/lib/matplotlib/collections.py
Line 381 in fc5d316
so gapcolor is only meaningful after this else.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.