Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: bad autolimit behavior with fill_between and transforms #21976

Open
@bmcfee

Description

@bmcfee

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

image

Expected outcome

If I force the ylimits on the second plot via

ax[1].set_ylim(ax[0].get_ylim())

it looks like
image

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp