annotate_heatmap#

gammapy.visualization.annotate_heatmap(im, data=None, valfmt='{x:.2f}', textcolors=('black', 'white'), threshold=None, **textkw)[source]#

A function to annotate a heatmap.

Parameters:
im

The AxesImage to be labeled.

datandarray, optional

Data used to annotate. Default is None. If None, the image’s data is used.

valfmtstr format or matplotlib.ticker.Formatter, optional

The format of the annotations inside the heatmap. This should either use the string format method, e.g. “$ {x:.2f}” or be a matplotlib.ticker.Formatter instance. Default is “{x:.2f}”.

textcolorslist or ndarray, optional

Two color specifications. The first is used for values below a threshold, the second for those above. Default is [“black”, “white”].

thresholdfloat, optional

Value in data units according to which the colors from textcolors are applied. Default is None. If None the middle of the colormap is used as separation.

**kwargsdict, optional

Other keyword arguments forwarded to each call to text used to create the text labels.