File: plot_frameless_image.py

package info (click to toggle)
sunpy 7.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,592 kB
  • sloc: python: 41,765; ansic: 1,710; makefile: 39
file content (45 lines) | stat: -rw-r--r-- 1,322 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
===============================
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
import numpy as np

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

##############################################################################
# Create a sunpy Map from the sample data.

smap = sunpy.map.Map(AIA_171_IMAGE)

##############################################################################
# Plot the Map without a frame.
# We can setup a frameless figure and an axes which spans the whole canvas.

figure = plt.figure(frameon=False)
ax = plt.axes([0, 0, 1, 1])
# Disable the axis
ax.set_axis_off()

# Plot the map.
# Since we are not interested in the exact map coordinates,
# we can simply use :meth:`~matplotlib.Axes.imshow`.
norm = smap.plot_settings['norm']
norm.vmin, norm.vmax = np.percentile(smap.data, [1, 99.9])
ax.imshow(smap.data,
          norm=norm,
          cmap=smap.plot_settings['cmap'],
          origin="lower")

# sphinx_gallery_defer_figures

##############################################################################
# At this point you could save the figure with :func:`~matplotlib.pyplot.savefig`
# or show it:

plt.show()