ema workbench

Other Sub Sites

plotting util

Code author: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>

plotting_util.COLOR_LIST = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'b', 'g', 'r', 'c', 'm', 'y', 'k']

Parameter controlling whether tight layout from matplotlib should be used

plotting_util.TIGHT = False

Default key for time

plotting_util.determine_kde(data, size_kde=1000, ymin=None, ymax=None)

Helper function responsible for performing a KDE

Parameters:data
plotting_util.determine_time_dimension(outcomes)
Parameters:outcomes
plotting_util.do_titles(ax, titles, outcome)

Helper function for setting the title on an ax

Parameters:
  • ax – the ax on which to set the title
  • titles – a dict which maps outcome names to titles
  • outcome – the outcome plotted in the ax.
plotting_util.do_ylabels(ax, ylabels, outcome)

Helper function for setting the y labels on an ax

Parameters:
  • ax – the ax on which to set the y label
  • titles – a dict which maps outcome names to y labels
  • outcome – the outcome plotted in the ax.
plotting_util.filter_scalar_outcomes(outcomes)

Helper function that removes non time series outcomes from all the outcomes.

Parameters:outcomes
Returns:the filtered outcomes
plotting_util.group_results(experiments, outcomes, group_by, grouping_specifiers)

Helper function that takes the experiments and results and returns a list based on groupings. Each element in the dictionary contains the experiments and results for a particular group, the key is the grouping specifier.

Parameters:
  • experiments
  • outcomes
  • group_by – The column in the experiments array to which the grouping specifiers apply. If the name is’index’ it is assumed that the grouping specifiers are valid indices for numpy.ndarray .
  • grouping_specifiers – An iterable of grouping specifiers. A grouping specifier is a unique identifier in case of grouping by categorical uncertainties. It is a tuple in case of grouping by a parameter uncertainty. In this cose, the code treats the tuples as half open intervals, apart from the last entry, which is treated as closed on both sides. In case of ‘index’, the iterable should be a dictionary with the name for each group as key and the value being a valid index for numpy.ndarray.
Returns:

A dictionary with the experiments and results for each group, the the grouping specifier is used as key

..note:: In case of grouping by parameter uncertainty, the list of
grouping specifiers is sorted. The traversal assumes half open intervals, where the upper limit of each interval is open, except for the last interval which is closed.
plotting_util.make_continuous_grouping_specifiers(array, nr_of_groups=5)

Helper function for discretesizing a continuous array. By default, the array is split into 5 equally wide intervals.

Parameters:
  • array – a 1-d array that is to be turned into discrete intervals.
  • nr_of_groups
Returns:

list of tuples with the lower and upper bound of the intervals.

Note

this code only produces intervals. group_results() uses these intervals in half-open fashion, apart from the last interval: [a, b), [b,c), [c,d]. That is, both the end point and the start point of the range of the continuous array are included.

plotting_util.make_grid(outcomes_to_show, density=None)

Helper function for making the grid that specifies the size and location of the various axes.

Parameters:
  • outcomes_to_show – the list of outcomes to show
  • density – boolean, whether to show density or not
plotting_util.make_legend(categories, figure, ncol=3, legend_type='line')
Parameters:
  • categories
  • figure
  • legend_type
plotting_util.plot_envelope(ax, j, time, value, fill)

Helper function, responsible for plotting an envelope.

Parameters:
  • ax
  • j
  • time
  • time
  • value
  • fill
plotting_util.plot_histogram(ax, values, log=False)

Helper function, responsible for plotting a histogram

Parameters:
  • ax
  • values
  • log
plotting_util.plot_kde(ax, kde_x, kde_y, j, log=False)

Helper function, responsible for plotting a KDE.

Parameters:
  • ax – the axes on which to plot the kde
  • kde_x – the x values of the kde
  • kde_y – the y values of the kde
  • j – the index of the group being shown
  • log – boolean, whether to log scale the data are not
plotting_util.prepare_data(results, outcomes_to_show=None, group_by=None, grouping_specifiers=None, filter_scalar=True)
Parameters:
  • results – the results to visualize
  • outcomes_to_show
  • group_by
  • grouping_specifiers
  • filter_scalar
plotting_util.prepare_pairs_data(results, outcomes_to_show=None, group_by=None, grouping_specifiers=None, point_in_time=-1, filter_scalar=True)
Parameters:
  • results
  • outcomes_to_show
  • group_by
  • grouping_specifiers
  • point_in_time
plotting_util.simple_density(density, value, ax_d, ax, loc=-1, **kwargs)

Helper function, responsible for producing a density plot

Parameters:
  • density – type of density
  • value – the data for which to calculate the density
  • ax_d
  • ax
  • kwargs
plotting_util.simple_kde(outcomes, outcomes_to_show, colormap, log, minima, maxima)

Helper function for generating a density heatmap over time

Parameters:
  • outcomes
  • outcomes_to_show
  • colormap
  • log
  • minima
  • maxima