Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Axes method for drawing infinite lines#9321

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
dstansby wants to merge2 commits intomatplotlib:masterfromdstansby:abline

Conversation

dstansby
Copy link
Member

@dstansbydstansby commentedOct 8, 2017
edited
Loading

Supersedes#7506 - cleans up docstring and adds a test.Fixes#5253.

@dstansbydstansby added this to the2.2 (next feature release) milestoneOct 8, 2017
@anntzer
Copy link
Contributor

Can you document how this interacts with semilog and loglog plots? (Even if it is "it doesn't work with them".)

dstansby and syrte reacted with thumbs up emoji

@dstansby
Copy link
MemberAuthor

Hmm, I can't reproduce the test failure

@QuLogic
Copy link
Member

You can download the results from AppVeyor:
axline-failed-diff
Wrong version of FreeType used for test?

@dstansbydstansby modified the milestones:v2.2,v3.0Jan 10, 2018
@syrte
Copy link

@anntzer I've tried this code, it seems not support any type of log scale yet.

@dstansby
Copy link
MemberAuthor

🎉 it works!

@tacaswell
Copy link
Member

what happens if we make it non-linear scale after callingaxline?

@QuLogic
Copy link
Member

Then you end up with a line that's incorrect in the same way as if it were set beforehand.

@NelleV
Copy link
Member

Can we refactor axhline and axvline as special cases of this function?

@NelleV
Copy link
Member

NelleV commentedJan 18, 2019
edited
Loading

I also think weshould add a what's new entry, and update the following example with this new function:https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/axhspan_demo.html#sphx-glr-gallery-subplots-axes-and-figures-axhspan-demo-py

thanks!

@NelleV
Copy link
Member

Reading axhline's and axvline's code, I see that it's not trivial (I do have to say that it's a bit annoying to have such closely related functions with slightly different APIs)

@dstansby
Copy link
MemberAuthor

Okay I've done a big 'ol rebase and squash, and this now usesxy1 andxy2.

Clean up axlineAdd axline image testFix test imageAdd what's newAdd note about log axesError if trying to draw line on non-linear axesFix scale checkingFix docstring interpolationChnage to using xy1, xy2Fix docs and closeness checkingRaise error if points are the sameSwap axline test to image comparison
@dstansby
Copy link
MemberAuthor

I think that's all the comments taken care of, so feel free to review again. I've squashed everything into one commit, so there's no extra test image files hanging around any more.

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add axline to the section „Span“ in axes_api.rst.

@anntzer
Copy link
Contributor

I just noticed another point: Currently, axline() does not trigger an update of the autolimits in use (for example a call to axline() when the view limits are x=0..1, y=0..1 leaves them unchanged); however, adding more plots after a call to axline() shows that the internal data limits have been changed by axline to include x=0..1, y=(whatever y range corresponds to x=0..1 in the axline). For example, afterplt.gca().axline((3, 7), (5, 6)); plt.plot([0, 1]), one gets
test

I think reasonable approaches would be to use the two points passed to axline() as "autoscaling limits", or to just not update the autoscale limits at all (the relevant code appears to be in Axes._update_line_limits, which is called by Axes.add_line).

@dstansby
Copy link
MemberAuthor

I agree that not setting auto-limits is a good idea, but after a bit of a play around I'm not sure what the right way to do that is. Is there an easy way to exclude anArtist from autoscale calculations?

@anntzer
Copy link
Contributor

This was discussed a while ago and there isn't really a smart way to do it; what I personally do is

@contextmanagerdef ignore_in_autoscale(ax):    """    When autoscaling, ignore the extents of artists created in the context.    """    dl = ax.dataLim.frozen()    try:        yield    finally:        ax.dataLim = dl        ax.autoscale_view(scalex=ax.get_autoscalex_on(),                          scaley=ax.get_autoscaley_on())

(basically, save the datalimits first, add the artist, then restore the datalimits), which is a bit of a hack.

@QuLogic
Copy link
Member

Replaced by#15330.

@dstansbydstansby deleted the abline branchNovember 26, 2019 15:41
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@NelleVNelleVNelleV left review comments

@tacaswelltacaswelltacaswell left review comments

@anntzeranntzeranntzer left review comments

@jklymakjklymakjklymak left review comments

@timhoffmtimhoffmtimhoffm left review comments

Assignees
No one assigned
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

abline() - for drawing arbitrary lines on a plot, given specifications.
8 participants
@dstansby@anntzer@QuLogic@syrte@tacaswell@NelleV@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp