hibou.utils.TaylorDiagramAxes#

class hibou.utils.TaylorDiagramAxes(*args, **kwargs)#

This class inherits from PolarAxes and modify this Axes subclass to looks like a Taylor diagram.

As TaylorDiagramAxes is a subclass of PolarAxes, all the common manipulations (e.g. set_title, legend, grid) are still functionnal.

Methods#

adjust_axes(is_extended: bool = False, corr_labels: array = None)#

Adjusts axes and the ticks of the Taylor diagram also plot the RMSD.

Parameters#

is_extendedbool, optionnal

By default: False. If set on True, the Taylor diagram will be extended to negative value of correlation coefficient.

corr_labelsnp.array, optionnal

By default:

np.array(
    [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 1]
)

The labels for the correlation ticks. You should pass floats. If is_extended is True, the corr_labels will be duplicated with a minus sign. So you should never have to pass negative values.

set_reference(reference: array, *args, **kwargs)#

Sets the reference for the normalization of the standard deviation. It also plot the point of reference on Taylor diagram.

Parameters#

referencenp.array

The data of reference.

args

Positionnal arguments to be passed to Axes.scatter.

kwargs

Keyword arguments to be passed to Axes.scatter.

add_point(data: array, *args, **kwargs)#

Adds a point the the Taylor diagram.

Parameters#

datanp.array

The data to be plotted on the diagram.

args

Positionnal arguments to be passed to Axes.scatter.

kwargs

Keyword arguments to be passed to Axes.scatter.

Examples#

A basic example:

import numpy as np
import matplotlib.pyplot as plt

from hibou.utils import TaylorDiagramAxes

# instanciate figure and axes
fig = plt.figure()
axes = fig.add_subplot(1, 1, 1, axes_class=TaylorDiagramAxes)

# data to plot on the Taylor diagram
ref_data = np.array([1, 2, 3])
data = np.array([0, 1, 2.5])

# plot points on the diagram
axes.set_reference(ref_data, marker="*", color="black", label="reference")
axes.add_point(data, label="data 1")

# finalize diagram and show
axes.adjust_axes()
axes.legend(loc="upper right", bbox_to_anchor=(0, 1))
plt.show()