Open
Description
Bug summary
Hi everyone,
I somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automatically
- clears the axes
- sets the scale
- sets the limits
- plots the data
In this case two warnings are issued. The code of the minimal example reproduces this behavior. When changing it to the second variant in the code block (first plotting the first column, then the second column) the issue disappears.
Thank you!
Best
Francesco
Code for reproduction
import numpy as np
from matplotlib import pyplot as plt
# ISSUE ARISES IN THIS VARIANT
fig, ax = plt.subplots(1, 2, sharey=True)
ax[1].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))
ax[1].set_yscale("log")
ax[1].set_ylim([1e0, 1e2])
ax[0].clear()
ax[0].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))
plt.show()
# NO ISSUE IN THE VARIANT BELOW
import numpy as np
from matplotlib import pyplot as plt
fig, ax = plt.subplots(1, 2, sharey=True)
ax[0].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))
ax[0].set_yscale("log")
ax[0].set_ylim([1e0, 1e2])
ax[1].clear()
ax[1].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))
plt.show()
Actual outcome
FutureWarning: Attempt to set non-positive ylim on a log-scaled axis will be ignored.
FutureWarning: Attempting to set identical low and high ylims makes transformation singular; automatically expanding.
Expected outcome
No warning is issued
Additional information
No response
Operating system
Windows
Matplotlib Version
3.10.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.11.11
Jupyter version
No response
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels