Editing the colormap and normalization of a Map

How to edit the display of a map.

import matplotlib.pyplot as plt
import matplotlib.colors as colors

import sunpy.map
from sunpy.data.sample import AIA_171_IMAGE

We start with the sample data

aiamap = sunpy.map.Map(AIA_171_IMAGE)

All plot settings for a map are stored in the plot_settings attribute. How a Map is displayed is determined by its colormap, which sets the colors , and the normalization, which sets how data values are translated to colors. Lets replace the colormap and normalization.

aiamap.plot_settings['cmap'] = plt.get_cmap('Greys_r')
aiamap.plot_settings['norm'] = colors.LogNorm(100, aiamap.max())

To see all of the colormaps SunPy provides see sunpy.cm. Matplotlib provides a number of colormaps and normalizations. For more advanced normalizations see astropy.visualization.

ax = plt.subplot(projection=aiamap)
aiamap.plot()
plt.colorbar()
plt.show()
../../../_images/sphx_glr_map_editcolormap_001.png

Total running time of the script: ( 0 minutes 0.724 seconds)

Gallery generated by Sphinx-Gallery