pyrolite
pyrolite copied to clipboard
[BUG] pyrolite passively influencing matplotlib legend placement
Describe the bug
pyrolite is somehow affecting the legend location in matplotlib and it is unrelated to the pyrolite.mplstyle file that comes with the package. Any time pyrolite is imported this happens, even when another .mplstyle file is included in the script.
I have even copied the .mplstyle legend params into a different style file and legends behave correctly, so this leads me to believe the problem is related to something else.
To Reproduce Steps to reproduce the behavior:
import numpy as np
import pyrolite
import matplotlib.pyplot as plt
legend_locations = [
"upper right",
"upper left",
"lower right",
"lower left",
"right",
"center left",
"center right",
"upper center",
"center",
]
n = len(legend_locations)
fig, ax = plt.subplots(n // 2, 2, figsize=(6, n // 2 * 3), layout="constrained")
axes = ax.ravel()
x = np.linspace(0, 1, 11)
for loc, a in zip(legend_locations, axes):
a.plot(x, x, color="k", marker="", ls="--", lw=0.5, label="test\nlabel")
a.set_title(loc, loc="left")
a.legend(loc=loc)
Expected behavior
The legend locations should be where matplotlib says they should be. Using the above example script without importing pyrolite yields:
Environment:
- OS: MacOS Sequoia 15.6.1
- Python Version: 3.12.11
- Pyrolite Version: 0.3.6