Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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
importmatplotlib.pyplotaspltimportnumpyasnpfrommatplotlib.transformsimportTransformclassTransformDemo(Transform):def__init__(self):super().__init__()self.input_dims=2self.output_dims=2self.is_separable=Falsedeftransform_non_affine(self,values):output=np.empty_like(values)output[:,0]=values[:,0]output[:,1]=100+values[:,1]/ (1+np.abs(values[:,0]))returnoutput# Make some random datay=np.random.randn(1000)x=np.arange(len(y))fig,ax=plt.subplots(ncols=2)T=TransformDemo()# First with plot, everything works as expectedax[0].plot(x,y,transform=T+ax[0].transData)# With fill_between, limits are not inferred correctlyax[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