-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Add Axes method for drawing infinite lines. #7506
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
Changes from all commits
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 |
---|---|---|
|
@@ -793,6 +793,69 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs): | |
self.autoscale_view(scalex=scalex, scaley=False) | ||
return l | ||
|
||
@docstring.dedent_interpd | ||
def axline(self, slope=1, intercept=0, **kwargs): | ||
""" | ||
Add an infinite line across the axes. | ||
|
||
Parameters | ||
---------- | ||
slope : scalar, optional, default: 1 | ||
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. Is there a reason this and intercept are optional? I would say the user should be forced to give them. |
||
Slope of the line. | ||
|
||
intercept : scalar, optional, default: 0 | ||
Intercept of the line with the y-axis. | ||
|
||
Returns | ||
------- | ||
:class:`~matplotlib.lines.Line2D` | ||
|
||
Other Parameters | ||
---------------- | ||
Valid kwargs are :class:`~matplotlib.lines.Line2D` properties, | ||
with the exception of 'transform': | ||
|
||
%(Line2D)s | ||
|
||
Examples | ||
-------- | ||
* draw a thick red line with slope 1 and y-intercept 0:: | ||
|
||
>>> axline(linewidth=4, color='r') | ||
|
||
* draw a default line with slope 1 and y-intercept 1:: | ||
|
||
>>> axline(intercept=1) | ||
|
||
* draw a default line with slope 5 and y-intercept 0:: | ||
|
||
>>> axline(slope=5) | ||
|
||
See Also | ||
-------- | ||
axhline : for strictly horizontal lines | ||
axvline : for strictly vertical lines | ||
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. Do these get automatically linked? If not would be nice to have some sphinx markup to link to relevant methods. |
||
|
||
""" | ||
|
||
if "transform" in kwargs: | ||
raise ValueError("'transform' is not allowed as a kwarg; " | ||
"axline generates its own transform.") | ||
|
||
xtrans = mtransforms.BboxTransformTo(self.viewLim) | ||
viewLimT = mtransforms.TransformedBbox( | ||
self.viewLim, | ||
mtransforms.Affine2D().rotate_deg(90).scale(-1, 1)) | ||
ytrans = (mtransforms.BboxTransformTo(viewLimT) + | ||
mtransforms.Affine2D().scale(slope).translate(0, intercept)) | ||
trans = mtransforms.blended_transform_factory(xtrans, ytrans) | ||
|
||
l = mlines.Line2D([0, 1], [0, 1], | ||
transform=trans + self.transData, | ||
**kwargs) | ||
self.add_line(l) | ||
return l | ||
|
||
@docstring.dedent_interpd | ||
def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs): | ||
""" | ||
|
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.
'across an axis'?