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

ENH: Possibilty to pass absolute values to axhline and axvline #15586

Closed
@jakobjakobson13

Description

@jakobjakobson13

Dear developers,

I have a enhancement proposal: Could you please add the possibility to pass absolute values to axhline and axvline?

Background
I found it a bit inconvenient to draw horizontal or vertical lines to mark maxima or minima using the relative values if you are plotting actual data.

Code example

importnumpyasnpimportmatplotlib.pyplotaspltfig,ax=plt.subplots()x=np.linspace(-1,1)defcurve(x):return-np.random.rand()*(2)*x**2-np.random.rand()# the random numbers have just been introduced to avoid an easy guessing of the numbers in the followingfixed_curve=curve(x)ax.plot(x,fixed_curve)ylim=ax.get_ylim()ytmp= (np.amax(fixed_curve)-ylim[0])/(ylim[1]-ylim[0])ax.axvline(0,0,ytmp)# better(?): ax.axvline(0, ylim[0], np.amax(fixed_curve), absolute = True)

Code explanation
In the example given above I want to mark to maximum with the coordinates (x, y) by a vertical line going from the maximum of the curve to the x axis to mark the value on the x axis. However, to exactly hit the maximum I first have to calculate the position of the maximum in respect the limits of the plot. Otherwise the line does either not "reach" the maximum or it "crosses" the maximum what would be counterintuitive.
This could be shortened by a parameterabsolute or similar that allows you to draw aaxvline oraxhline from one absolute coordinate to another absolute coordinate.

What do you think about that suggestion?

Regards

Jakob

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp