Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
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.
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
Labels
No labels