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

[Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used #28673

Closed
@kjayawar

Description

@kjayawar

Bug summary

When ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored

Code to reproduce the error

importmatplotlib.pyplotaspltimportnumpyasnp# Generate some random datax=np.arange(0,10,0.1)y=np.random.randn(len(x))# Create a plotfig,ax=plt.subplots()plt.ion()ax.set_aspect('equal','datalim')# Set x-axis limitsax.set_xlim(2,5)# Print the x and y limitsprint(f"x-axis limits before plotting:{ax.get_xlim()}")print(f"y-axis limits before plotting:{ax.get_ylim()}")ax.plot(x,y*10)# Print the x and y limitsprint(f"x-axis limits after plotting:{ax.get_xlim()}")print(f"y-axis limits after plotting:{ax.get_ylim()}")# Set x-axis limitsax.set_xbound(lower=2,upper=5)# ax.set_xlim(2, 5)# Print the x and y limitsprint(f"x-axis limits after setting xlim:{ax.get_xlim()}")print(f"y-axis limits after setting xlim:{ax.get_ylim()}")# Show the plotplt.show()

What is been tried to mitigate the issue
ax._autoscaleXon = False

Actual outcome

This code produces a plot with x-axis not limited to the given xrange 2-5.
image

Expected outcome

xlimit obeys the given range, with y range automatically adjusted to the given aspect ratio

Additional information

No response

Operating system

windows

Matplotlib Version

3.8.2

Matplotlib Backend

QtAgg

Python version

Python 3.9.7

Jupyter version

No response

Installation

pip

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