| 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Allow for custom marker scaling | ||
| ------------------------------- | ||
| `~.markers.MarkerStyle` gained a keyword argument *normalization*, which may be | ||
| set to *"none"* to allow for custom paths to not be scaled.:: | ||
|
|
||
| MarkerStyle(Path(...), normalization="none") | ||
|
|
||
| `~.markers.MarkerStyle` also gained a `~.markers.MarkerStyle.set_transform` | ||
| method to set affine transformations to existing markers.:: | ||
|
|
||
| m = MarkerStyle("d") | ||
| m.set_transform(m.get_transform() + Affine2D().rotate_deg(30)) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -201,7 +201,8 @@ class MarkerStyle: | |||||||||
| # TODO: Is this ever used as a non-constant? | ||||||||||
| _point_size_reduction = 0.5 | ||||||||||
|
|
||||||||||
| def __init__(self, marker=None, fillstyle=None): | ||||||||||
| def __init__(self, marker=None, fillstyle=None, *, | ||||||||||
| normalization="classic"): | ||||||||||
| """ | ||||||||||
| Attributes | ||||||||||
| ---------- | ||||||||||
| Expand All | @@ -213,12 +214,23 @@ def __init__(self, marker=None, fillstyle=None): | |||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| marker : str or array-like, optional, default: None | ||||||||||
| marker : str, array-like, `~.path.Path`, or `~.markers.MarkerStyle`, \ | ||||||||||
| default: None | ||||||||||
|
Comment thread
ImportanceOfBeingErnest marked this conversation as resolved.
|
||||||||||
| See the descriptions of possible markers in the module docstring. | ||||||||||
|
|
||||||||||
| fillstyle : str, optional, default: 'full' | ||||||||||
| 'full', 'left", 'right', 'bottom', 'top', 'none' | ||||||||||
|
|
||||||||||
| normalization : str, {'classic', 'none'}, optional, default: "classic" | ||||||||||
| The normalization of the marker size. Only applies to custom paths | ||||||||||
| that are provided as array of vertices or `~.path.Path`. | ||||||||||
| Can take two values: | ||||||||||
| *'classic'*, being the default, makes sure the marker path is | ||||||||||
|
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 Qualityclassic is a confusing name, because it overlaps with the classic style, but it's not the classic style (I mean it is also the classic style, but not only the classic style.)
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
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 might be misreading this comment, but it seems like it's not that classic is a confusing name, but that the docstring here is not correct. According to the discussion above. The docstring should read (if I understand correctly): *'classic'*, being the default, ensures built-in markers maintain the size they have always had, and for custom markers it makes sure the marker path is normalized to fit within a unit-square by affine scaling. This is exactly the classic style, as far as I can tell.
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 QualityHence the sentence "Only applies to custom paths...". So this is definitely correct. I'm happy to use a name other than "classic", but since I find that name fits pretty well, I would need input with alternative ideas. I guess this is also secondary compared to naming the argument itself - for which there is also no consensus yet it seems.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
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 QualityTo be clear, I am 100% behind the "classic" name. I think it is consistently applied and fits well. I am also very happy with "normalization". However, wasn't one of the main benefits (and the impetus for this PR being revisited) that adding a "normalization" kwarg would allow us to address #15703? If so, I think that stating in the initial docstring that it only applies to custom paths (maybe just add "for now" if you don't like my more verbose wording).
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 QualityI'm cautious to document any possible future behaviour. (We had some new normalization or the toolmanager being anounced as "coming soon" for years, which doesn't really help people using the library in the present.)
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
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 Quality100% onboard with not documenting "possible" future behavior. On the other hand, a wording closer to mine doesn't close the door to this feature (which is already implemented in my "paths" PR stack). Mostly just being selfish because I have a strong feeling that if the current phrasing of the docstring gets merged, I'll get pushback when I try to change it in my own PR, whereas an equally specific and correct version could be written that doesn't specify that this keyword "only applies to custom paths". As far as I'm concerned, feel free to merge this as-is and I'll just have that fight when it's time.
Sorry, something went wrong.
All reactions
|
||||||||||
| normalized to fit within a unit-square by affine scaling. | ||||||||||
| *'none'*, in which case no scaling is performed on the marker path. | ||||||||||
| """ | ||||||||||
| cbook._check_in_list(["classic", "none"], normalization=normalization) | ||||||||||
| self._normalize = normalization | ||||||||||
| self._marker_function = None | ||||||||||
| self.set_fillstyle(fillstyle) | ||||||||||
| self.set_marker(marker) | ||||||||||
| Expand Down Expand Up | @@ -303,6 +315,13 @@ def get_path(self): | |||||||||
| def get_transform(self): | ||||||||||
| return self._transform.frozen() | ||||||||||
|
|
||||||||||
| def set_transform(self, transform): | ||||||||||
| """ | ||||||||||
| Sets the transform of the marker. This is the transform by which the | ||||||||||
|
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 QualityFirst line of docstring should be separate.
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||
| marker path is transformed. | ||||||||||
| """ | ||||||||||
| self._transform = transform | ||||||||||
|
|
||||||||||
| def get_alt_path(self): | ||||||||||
| return self._alt_path | ||||||||||
|
|
||||||||||
| Expand All | @@ -316,8 +335,9 @@ def _set_nothing(self): | |||||||||
| self._filled = False | ||||||||||
|
|
||||||||||
| def _set_custom_marker(self, path): | ||||||||||
| rescale = np.max(np.abs(path.vertices)) # max of x's and y's. | ||||||||||
| self._transform = Affine2D().scale(0.5 / rescale) | ||||||||||
| if self._normalize == "classic": | ||||||||||
| rescale = np.max(np.abs(path.vertices)) # max of x's and y's. | ||||||||||
| self._transform = Affine2D().scale(0.5 / rescale) | ||||||||||
| self._path = path | ||||||||||
|
|
||||||||||
| def _set_path_marker(self): | ||||||||||
| Expand Down Expand Up | @@ -350,8 +370,6 @@ def _set_tuple_marker(self): | |||||||||
| def _set_mathtext_path(self): | ||||||||||
| """ | ||||||||||
| Draws mathtext markers '$...$' using TextPath object. | ||||||||||
|
|
||||||||||
| Submitted by tcb | ||||||||||
| """ | ||||||||||
| from matplotlib.text import TextPath | ||||||||||
|
|
||||||||||
| 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 Qualityis there a reason this can't be a transform= kwarg? ie transform=None would do what we did before...
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.