Plotting¶
PlotUncertainty
creates plot of the data
from the uncertainty quantification and sensitivity analysis.
PlotUncertainpy
plots the results for all zero and one dimensional statistical
metrics, and some of the two dimensional statistical metrics
It is intended as a quick way to get an overview of the data, and does not
create publication ready plots.
Custom plots of the data can easily be created by retrieving the results from
the Data class.
API Reference¶

class
uncertainpy.plotting.
PlotUncertainty
(filename=None, folder=u'figures/', figureformat=u'.png', logger_level=u'info')[source]¶ Plotting the results from the uncertainty quantification and sensitivity analysis.
Parameters:  filename ({None, str}, optional) – The name of the data file. If given the file is loaded. If None, no file is loaded. Default is None.
 folder (str, optional) – The folder where to save the plots. Creates a new folder if it does not exist. Default is “figures/”.
 figureformat (str, optional) – The format to save the plots in. Given as “.xxx”. All formats supported by Matplotlib are available. Default is “.png”,
 logger_level ({“info”, “debug”, “warning”, “error”, “critical”, None}, optional) – Set the threshold for the logging level. Logging messages less severe than this level is ignored. If None, no logging to file is performed Default logger level is “info”.
Variables:  folder (str) – The folder where to save the plots.
 figureformat (str, optional) – The format to save the plots in. Given as “.xxx”. All formats supported by Matplotlib are available.
 data (Data) – A data object that contains the results from the uncertainty quantification. Contains all model and feature values, as well as all calculated statistical metrics.

all_evaluations
(foldername=u'evaluations')[source]¶ Plot all evaluations for all model and features.
Parameters: foldername (str, optional) – Name of folder where to save all plots. The folder is created if it does not exist. Default folder is named “evaluations”.

attribute_feature_1d
(feature=None, attribute=u'mean', attribute_name=u'mean', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot a 1 dimensional attribute for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 attribute ({“mean”, “variance”}, optional) – Attribute to plot, either the mean or variance. Default is “mean”.
 attribute_name (str) – Name of the attribute, used as title and name of the plot. Default is “mean”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.ValueError
– If the attribute is not a supported attribute, either “mean” or “variance”.

attribute_feature_2d
(feature=None, attribute=u'mean', attribute_name=u'mean', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot a 2 dimensional attribute for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 attribute ({“mean”, “variance”}, optional) – Attribute to plot, either the mean or variance. Default is “mean”.
 attribute_name (str) – Name of the attribute, used as title and name of the plot. Default is “mean”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 2 dimensional.ValueError
– If the attribute is not a supported attribute, either “mean” or “variance”.

average_sensitivity
(feature, sensitivity=u'first', hardcopy=True, show=False)[source]¶ Plot the average of the sensitivity for a specific model/feature.
Parameters:  feature ({None, str}) – The name of the model/feature. If None, the name of the model is used. Default is None.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.ValueError
– If feature does not exist.

average_sensitivity_all
(sensitivity=u'first', hardcopy=True, show=False)[source]¶ Plot the average of the sensitivity for all model/features.
Parameters:  sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

average_sensitivity_grid
(sensitivity=u'first', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the average of the sensitivity for all model/features in their own plots in the same figure.
Parameters:  sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

convert_sensitivity
(sensitivity)[source]¶ Convert a sensitivity str to the correct sensitivity attribute, and a full name.
Parameters: sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”, None}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Returns:  sensitivity (str) – Name of the sensitivity attribute. Either sobol_first”, “sobol_total”, or the unchanged input.
 full_text (str) – Complete name of the sensitivity. Either “”, or “first order Sobol indices” or “total order Sobol indices”.

evaluations
(feature=None, foldername=u'', **plot_kwargs)[source]¶ Plot all evaluations for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 foldername (str, optional) – Name of folder where to save all plots. The folder is created if it does not exist. Default folder is named “featurename_evaluations”.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.NotImplementedError
– If the model/feature have more than 2 dimensions.AttributeError
– If the dimensions of the evaluations is not valid.

evaluations_0d
(feature=None, foldername=u'', **plot_kwargs)[source]¶ Plot all 0D evaluations for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 foldername (str, optional) – Name of folder where to save all plots. The folder is created if it does not exist.Default folder is named “featurename_evaluations”.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the evaluations are not 0 dimensional.

evaluations_1d
(feature=None, foldername=u'', **plot_kwargs)[source]¶ Plot all 1D evaluations for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 foldername (str, optional) – Name of folder where to save all plots. The folder is created if it does not exist. Default folder is named “featurename_evaluations”.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the evaluations are not 1 dimensional.

evaluations_2d
(feature=None, foldername=u'', **plot_kwargs)[source]¶ Plot all 2D evaluations for a specific model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 foldername (str, optional) – Name of folder where to save all plots. The folder is created if it does not exist. Default folder is named “featurename_evaluations”.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the evaluations are not 2 dimensional.

feature_0d
(feature, sensitivity=u'first', hardcopy=True, show=False, max_legend_size=5)[source]¶ Plot all attributes (mean, variance, p_05, p_95 and sensitivity of it exists) for a 0 dimensional model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”, None}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. If None, no sensitivity is plotted. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 max_legend_size (int, optional) – The max number of legends in a row. Default is 5.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 0 dimensional.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, “total” or None.

features_0d
(sensitivity=u'first', hardcopy=True, show=False)[source]¶ Plot the results for all 0 dimensional model/features.
Parameters:  sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

features_1d
(sensitivity=u'first')[source]¶ Plot all data for all 1 dimensional model/features.
For each model/feature plots
mean_1d
,variance_1d
,mean_variance_1d
, andprediction_interval_1d
. If sensitivity also plotsensitivity_1d
,sensitivity_1d_combined
, andsensitivity_1d_grid
.Parameters: sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”, None}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. If None, no sensitivity is plotted. Default is “first”.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, “total” or None.
See also
uncertainpy.plotting.PlotUncertainty.mean_1d()
,uncertainpy.plotting.PlotUncertainty.variance_1d()
,uncertainpy.plotting.PlotUncertainty.mean_variance_1d()
,uncertainpy.plotting.PlotUncertainty.prediction_interval_1d()
,uncertainpy.plotting.PlotUncertainty.sensitivity_1d()
,uncertainpy.plotting.PlotUncertainty.sensitivity_1d_combined()
,uncertainpy.plotting.PlotUncertainty.sensitivity_1d_grid()

features_2d
()[source]¶ Plot all implemented plots for all 2 dimensional model/features. For each model/feature plots
mean_2d
, andvariance_2d
.Raises: ValueError
– If a Datafile is not loaded.

folder
¶ The folder where to save all plots.
Parameters: new_folder (str) – Name of new folder where to save all plots. The folder is created if it does not exist.

load
(filename)[source]¶ Load data from a HDF5 or Exdir file with name filename.
Parameters: filename (str) – Name of the file to load data from.

mean_1d
(feature, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the mean for a specific 1 dimensional model/feature.
Parameters:  feature (str) – The name of the model/feature.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.

mean_2d
(feature, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the mean for a specific 2 dimensional model/feature.
Parameters:  feature (str) – The name of the model/feature.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 2 dimensional.

mean_variance_1d
(feature=None, new_figure=True, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the mean and variance for a specific 1 dimensional model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.

plot
(condensed=True, sensitivity=u'first')[source]¶ Plot the subset of data that shows all information in the most concise way, with the chosen sensitivity.
Parameters:  condensed (bool, optional) – If the results should be plotted in the most concise way. If not, all plots are created. Default is True.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. If None, no sensitivity is plotted. Default is “first”.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, “total”, or None.

plot_all
(sensitivity=u'first')[source]¶ Plot the results for all model/features, with the chosen sensitivity.
Parameters: sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”, None}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. If None, no sensitivity is plotted. Default is “first”.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, “total”, or None.

plot_all_sensitivities
()[source]¶ Plot the results for all model/features, with all sensitivities.
Raises: ValueError
– If a Datafile is not loaded.

plot_condensed
(sensitivity=u'first')[source]¶ Plot the subset of data that shows all information in the most concise way, with the chosen sensitivity.
Parameters: sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. If None, no sensitivity is plotted. Default is “first”.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, “total”, or None.

prediction_interval_1d
(feature=None, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the prediction interval for a specific 1 dimensional model/feature.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.

sensitivity_1d
(feature=None, sensitivity=u'first', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the sensitivity for a specific 1 dimensional model/feature. The Sensitivity for each parameter is plotted in sepearate figures.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

sensitivity_1d_combined
(feature=None, sensitivity=u'first', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the sensitivity for a specific 1 dimensional model/feature. The Sensitivity for each parameter is plotted in the same plot.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

sensitivity_1d_grid
(feature=None, sensitivity=u'first', hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the sensitivity for a specific 1 dimensional model/feature. The Sensitivity for each parameter is plotted in the same figure, but separate plots.
Parameters:  feature ({None, str}, optional) – The name of the model/feature. If None, the name of the model is used. Default is None.
 sensitivity ({“sobol_first”, “first”, “sobol_total”, “total”}, optional) – Which Sobol indices to plot. “sobol_first” and “first” is the first order Sobol indices, while “sobol_total” and “total” are the total order Sobol indices. Default is “first”.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.ValueError
– If sensitivity is not one of “sobol_first”, “first”, “sobol_total”, or “total”.

variance_1d
(feature, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the variance for a specific 1 dimensional model/feature.
Parameters:  feature (str) – The name of the model/feature.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 1 dimensional.

variance_2d
(feature, hardcopy=True, show=False, **plot_kwargs)[source]¶ Plot the variance for a specific 2 dimensional model/feature.
Parameters:  feature (str) – The name of the model/feature.
 hardcopy (bool, optional) – If the plot should be saved to file. Default is True.
 show (bool, optional) – If the plot should be shown on screen. Default is False.
 **plot_kwargs, optional – Matplotlib plotting arguments.
Raises: ValueError
– If a Datafile is not loaded.ValueError
– If the model/feature is not 2 dimensional.