visualization - Plotting and visualization

Getting started

gammapy.visualization provides a few helper functions and classes to create publication-quality images.


The following example shows how to plot images using colormaps that are commonly used in gamma-ray astronomy (colormap_hess and colormap_milagro).

(png, hires.png, pdf)


Survey panel plots

The MapPanelPlotter allows to split e.g. a galactic plane survey image with a large aspect ratio into multiple panels. Here is a short example:

(png, hires.png, pdf)



gammapy.visualization Package


annotate_heatmap(im[, data, valfmt, …])

A function to annotate a heatmap.

colormap_hess([transition, width])

Colormap often used in H.E.S.S.

colormap_milagro([transition, width, huestart])

Colormap often used in Milagro collaboration publications.

plot_contour_line(ax, x, y, **kwargs)

Plot smooth curve from contour points

plot_heatmap(data, row_labels, col_labels[, …])

Create a heatmap from a numpy array and two lists of labels.


Plot the off regions of spectrum datasets.


Plot the theta2 distribution of ON, OFF counts, excess and signifiance in each theta2bin.


MapPanelPlotter(figure, xlim, ylim[, npanels])

Map panel plotter class.