-
Notifications
You must be signed in to change notification settings - Fork 36
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
Alpha argument added to BezierTriangle and CurvedPolygon plotting functions #296
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,14 +62,15 @@ def add_plot_boundary(ax, padding=0.125): | |||||
) | ||||||
|
||||||
|
||||||
def add_patch(ax, color, pts_per_edge, *edges): | ||||||
def add_patch(ax, color, pts_per_edge, *edges, alpha=None): | ||||||
"""Add a polygonal surface patch to a plot. | ||||||
|
||||||
Args: | ||||||
ax (matplotlib.artist.Artist): A matplotlib axis. | ||||||
color (Tuple[float, float, float]): Color as RGB profile. | ||||||
pts_per_edge (int): Number of points to use in polygonal | ||||||
approximation of edge. | ||||||
alpha (Optional[float]): Alpha value of patch centre, between 0 and 1 inclusive. | ||||||
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.
Suggested change
American spelling? For consistency? 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. Ah yep, thanks! I'm an aussie, so that spelling was mostly muscle memory for me 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. No worries! |
||||||
*edges (Tuple[~bezier.curve.Curve, ...]): Curved edges defining | ||||||
a boundary. | ||||||
""" | ||||||
|
@@ -99,6 +100,6 @@ def add_patch(ax, color, pts_per_edge, *edges): | |||||
# column but ``Path()`` wants ``x-y`` points in each row. | ||||||
path = _path_mod.Path(polygon.T) | ||||||
patch = patches.PathPatch( | ||||||
path, facecolor=color, edgecolor=color, alpha=0.625 | ||||||
path, facecolor=color, edgecolor=color, alpha=(alpha or 0.625) | ||||||
) | ||||||
ax.add_patch(patch) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -259,20 +259,21 @@ def __repr__(self): | |||||
""" | ||||||
return f"<{self.__class__.__name__} (num_sides={self._num_sides:d})>" | ||||||
|
||||||
def plot(self, pts_per_edge, color=None, ax=None): | ||||||
def plot(self, pts_per_edge, color=None, ax=None, alpha=None): | ||||||
"""Plot the current curved polygon. | ||||||
|
||||||
Args: | ||||||
pts_per_edge (int): Number of points to plot per curved edge. | ||||||
color (Optional[Tuple[float, float, float]]): Color as RGB profile. | ||||||
ax (Optional[matplotlib.artist.Artist]): matplotlib axis object | ||||||
to add plot to. | ||||||
alpha (Optional[float]): Alpha value of patch centre, between 0 and 1 inclusive. | ||||||
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.
Suggested change
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. I'll get this one too, thanks! |
||||||
|
||||||
Returns: | ||||||
matplotlib.artist.Artist: The axis containing the plot. This | ||||||
may be a newly created axis. | ||||||
""" | ||||||
if ax is None: | ||||||
ax = _plot_helpers.new_axis() | ||||||
_plot_helpers.add_patch(ax, color, pts_per_edge, *self._edges) | ||||||
_plot_helpers.add_patch(ax, color, pts_per_edge, *self._edges, alpha=alpha) | ||||||
return ax |
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.
This should just be
based on the usage below, right?
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.
Looking at the rest of the changes, I think it's fine to default to
alpha=0.625
everywhere.Though I appreciate why you went with
alpha=None
as the API choice.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.
Np, I'll switch over to 0.625 then