Plotting a Map without any Axes

This examples shows you how to plot a Map without any annotations at all, i.e. to save as an image.

import matplotlib.pyplot as plt

Start by importing the necessary modules.

import astropy.units as u

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

Create a sunpy.map.GenericMap.

smap = sunpy.map.Map(AIA_171_IMAGE)

Plot the Map without a frame.

# Setup a frameless figure and an axes which spans the whole canvas.
figure = plt.figure(frameon=False)
axes = plt.Axes(figure, [0., 0., 1., 1.])

# Disable the axis and add them to the figure.
axes.set_axis_off()
figure.add_axes(axes)

# Plot the map without any annotations
# This might raise a warning about the axes being wrong but we can ignore this
# as we are not plotting any axes.
im = smap.plot(axes=axes, annotate=False, clip_interval=(1, 99.99)*u.percent)
plot frameless image

Out:

/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/sunpy/map/mapbase.py:2048: SunpyUserWarning: WCSAxes not being used as the axes object for this plot. Plots may have unexpected behaviour. To fix this pass 'projection=map' when creating the axes
  warnings.warn("WCSAxes not being used as the axes object for this plot."
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/sunpy/map/mapbase.py:2054: SunpyUserWarning: The axes of this map are not aligned to the pixel grid. Plot axes may be incorrect.
  warnings.warn("The axes of this map are not aligned to the pixel grid. Plot axes may be incorrect.",
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/sunpy/map/mapbase.py:2101: MatplotlibDeprecationWarning: Passing parameters norm and vmin/vmax simultaneously is deprecated since 3.3 and will become an error two minor releases later. Please pass vmin/vmax directly to the norm when creating it.
  ret = axes.imshow(self.data, **imshow_args)

At this point you could save the figure with plt.savefig() or show it:

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

Gallery generated by Sphinx-Gallery