twinlab.Emulator.heatmap#

Emulator.heatmap(x1_axis, x2_axis, y_axis, x_fixed={}, mean_or_std='mean', params=<twinlab.params.PredictParams object>, x1_lim=(None, None), x2_lim=(None, None), y_lim=(None, None), n_points=25, cmap=<matplotlib.colors.LinearSegmentedColormap object>, figsize=(6.4, 4.8), verbose=False)[source]#

Plot a heatmap of the predictions from an emulator across two dimensions.

This will make a call to the emulator to predict across the specified dimensions. Note that a higher-than-two-dimensional emulator will be sliced across the other dimensions. The matplotlib.pyplot object is returned, and can be further modified by the user. The uncertainty of the emulator is not plotted here.

Parameters:
  • x1_axis (str) – The name of the x1-axis variable (horizonal axis).

  • x2_axis (str) – The name of the x2-axis variable (vertical axis).

  • y_axis (str) – The name of the plotted variable (heatmap).

  • x_fixed (dict, optional) – A dictionary of fixed values for the other X variables. Note that all X variables of an emulator must either be specified as x1_axis, x2_axis or appear as keys in x_fixed. Passing an empty dictionary (the default) will fix none of the variables.

  • mean_or_std (str, optional) – A string determining whether to plot the mean ("mean") or standard deviation ("std") of the emulator. Defaults to "mean".

  • params (PredictParams) – (PredictParams, optional). A parameter configuration that contains optional prediction parameters.

  • x1_lim (tuple[float, float], optional) – The limits of the x1-axis. If not provided, the limits will be taken directly from the emulator.

  • x2_lim (tuple[float, float], optional) – The limits of the x2-axis. If not provided, the limits will be taken directly from the emulator.

  • y_lim (tuple[float, float], optional) – The limits of the y-axis; this is the colorbar.

  • n_points (int, optional) – The number of points to sample in each dimension. The default is 25, which will create a 25x25 grid.

  • cmap (str, optional) – The color of the plot. Defaults to a digiLab palette. Can be any valid matplotlib color (https://matplotlib.org/stable/users/explain/colors/colormaps.html).

  • verbose (bool, optional) – Display detailed information about the operation while running.

Returns:

Matplotlib plot object

Return type:

matplotlib.pyplot

Examples

emulator = tl.Emulator("emulator_id") # A trained emulator
plt = emulator.heatmap("Latitude", "Longitude", "Rainfall", x_fixed={"Month": 6})
plt.show()