diff --git a/changelog/7261.bugfix.rst b/changelog/7261.bugfix.rst new file mode 100644 index 00000000000..ff3100128ac --- /dev/null +++ b/changelog/7261.bugfix.rst @@ -0,0 +1 @@ +Fixed a bug with :meth:`sunpy.map.GenericMap.plot` where setting ``norm`` to ``None`` would result in an error. diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py index 5090185bfce..089157a6b2c 100644 --- a/sunpy/map/mapbase.py +++ b/sunpy/map/mapbase.py @@ -2526,7 +2526,7 @@ def plot(self, annotate=True, axes=None, title=True, autoalign=False, msg = ('Cannot manually specify {0}, as the norm ' 'already has {0} set. To prevent this error set {0} on ' '`m.plot_settings["norm"]` or the norm passed to `m.plot`.') - if 'norm' in imshow_args: + if imshow_args.get('norm', None) is not None: norm = imshow_args['norm'] if 'vmin' in imshow_args: if norm.vmin is not None: diff --git a/sunpy/map/tests/test_mapbase.py b/sunpy/map/tests/test_mapbase.py index 0420b63b566..ae903ff41f1 100644 --- a/sunpy/map/tests/test_mapbase.py +++ b/sunpy/map/tests/test_mapbase.py @@ -1153,6 +1153,12 @@ def test_as_mpl_axes_aia171(aia171_test_map): assert all([ct1 == ct2 for ct1, ct2 in zip(ax.wcs.wcs.ctype, aia171_test_map.wcs.wcs.ctype)]) +def test_plot_with_norm_none(aia171_test_map): + # Confirm that norm == None does not raise an error, see https://github.com/sunpy/sunpy/pull/7261 + ax = plt.subplot(projection=aia171_test_map) + aia171_test_map.plot(axes=ax, norm=None, vmin=0, vmax=0) + + def test_validate_meta(generic_map): """Check to see if_validate_meta displays an appropriate error""" with pytest.warns(SunpyMetadataWarning) as w: