-
-
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
Conversation
This is pretty neat! Given |
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 also needs a what's new entry, at least an image test, and some edge case tests too. (slope zero, negative slope, very large slope are the ones that come to my mind right now). Otherwise looks good!
@@ -794,6 +794,69 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs): | |||
return l | |||
|
|||
@docstring.dedent_interpd | |||
def axline(self, slope=1, intercept=0, **kwargs): | |||
""" | |||
Add an infinite line across the axes. |
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'?
|
||
Parameters | ||
---------- | ||
slope : scalar, optional, default: 1 |
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.
Is there a reason this and intercept are optional? I would say the user should be forced to give them.
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 comment
The 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.
A tentative suggestion on arguments, how about following forms:
Accept following combinations:
This may cover most forms as suggeted by #5253 . Surely, we may assign default value to |
@QuLogic do you have any plans to work on this? If not let me know and I'm happy to pick it up. I think it would be a cool and useful feature to add. |
I don't really have time at the moment, so feel free to prepare something based on it. |
Closing in favour of #9321 |
This is an implementation of an infinite line artist following the transforms I outlined in #5253. However, I did need to change from
ax.dataLim
toax.viewLim
because the former is infinite when nothing else is on the plot. I'm not sure if that will cause problems (maybe in log-scaled plots?), though it seems to work:Unlike
axhline
andaxvline
, there is no[xy]{min,max}
or autoscaling based on these artists because I don't think it makes sense for infinite lines.I've only implemented
slope
/intercept
and not any of the alternates in #5253; not sure which ones we want to support. Also needs some tests, wrapper inpyplot
, etc., so it's still WIP.