Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unexpected change in behavior in plt.subplot #19432

Closed
@astrofrog

Description

@astrofrog

Bug report

Bug summary

#19153 introduced some changes that had (I think) unintended consequences when passing custom kwargs to projections

Code for reproduction

Prior to #19153, the following code returned False, that is, two different axes were created:

from astropy.wcs import WCS
import matplotlib.pyplot as plt

wcs1 = WCS(naxis=3)
wcs1.wcs.ctype = ['x', 'y', 'z']

ax1 = plt.subplot(1, 1, 1, projection=wcs1, slices=('x', 'y', 1))

wcs2 = WCS(naxis=3)
wcs2.wcs.ctype = ['a', 'b', 'c']

ax2 = plt.subplot(1, 1, 1, projection=wcs2, slices=('x', 2, 'y'))

print(ax1 is ax2)

No deprecation warning or future warning was raised in this case.

Following #19153, this silently ignores the projection and slices in the second call and the print statement returns True.

I don't think #19153 was intended to start making plt.subplot return the same axes in some cases, rather I thought the goal of that PR was to remove re-use of axes in certain circumstances, so I think this is a regression/bug

Actual outcome

ax1 and ax2 are the same

Expected outcome

ax1 and ax2 should be different

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions