Open
Description
Bug summary
Using a fill_between artist with a custom transform to displace data along the y-axis, the autolimiting behavior does not work as I would expect: the axes use the non-transformed data extents. A normal line plot with the same transform does work as I would expect: autolimits match the transformed data.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.transforms import Transform
class TransformDemo(Transform):
def __init__(self):
super().__init__()
self.input_dims = 2
self.output_dims = 2
self.is_separable = False
def transform_non_affine(self, values):
output = np.empty_like(values)
output[:, 0] = values[:, 0]
output[:, 1] = 100 + values[:, 1] / (1 + np.abs(values[:, 0]))
return output
# Make some random data
y = np.random.randn(1000)
x = np.arange(len(y))
fig, ax = plt.subplots(ncols=2)
T = TransformDemo()
# First with plot, everything works as expected
ax[0].plot(x, y, transform=T + ax[0].transData)
# With fill_between, limits are not inferred correctly
ax[1].fill_between(x, -np.abs(y), np.abs(y), transform=T + ax[1].transData)
Actual outcome
Expected outcome
If I force the ylimits on the second plot via
ax[1].set_ylim(ax[0].get_ylim())
which is basically how I would expect.
Additional information
I'm not sure that the plot behavior is actually to spec here, but the disagreement between the two artists' behavior seems to me like a bug somewhere.
Operating system
Ubuntu
Matplotlib Version
3.5.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
sys.version_info(major=3, minor=9, micro=7, releaselevel='final', serial=0)
Jupyter version
3.2.5 (dev), 3.2.4 (app)
Installation
conda
Metadata
Metadata
Assignees
Labels
No labels