sunpeek.common.plot_utils#

This module is intended to hold some plot-related utilities that are used in the SunPeek Python package.

Plotting is primarily used to generate visual results for the Performance Check (PC) method, see sunpeek/core_methods/pc_method. Similar plots are generated for the D-CAT methods, see sunpeek/core_methods/dcat (Note: D-CAT methods currently under development).

The goal is to have common settings for matplotlib based plot creation (like colorblind-friendly colors etc.), and a common interface to plot methods (see PlotResult etc.).

Some helpful matplotlib-related resources: - https://matplotlib.org/stable/gallery/text_labels_and_annotations/demo_annotation_box.html - https://matplotlib.org/stable/tutorials/intermediate/legend_guide.html - https://matplotlib.org/stable/tutorials/advanced/transforms_tutorial.html - packing text (HPacker, VPacker): https://stackoverflow.com/questions/63659519/plotting-text-using-textarea-and-annotationbbox-in-matplotlib - https://matplotlib.org/stable/gallery/ticks/date_concise_formatter.html - https://matplotlib.org/stable/api/ticker_api.html - Customize matplotlib rc params: https://matplotlib.org/stable/tutorials/introductory/customizing.html - matplotlib mathtext: https://matplotlib.org/stable/tutorials/text/mathtext.html

Functions

add_table(ax, df[, col_formats, ...])

Create matplotlib table using only standard components (text, plot etc.).

annotation_bbox(box, xy[, xycoords, xybox, ...])

Returns a normal AnnotationBbox.

anonymize(d[, do_anonymize, anon_txt, na_txt])

Replace empty values with 'N/A', and sensitive information with '<anonymized>' string.

box_title(title_str[, textprops, fontsize])

Create default title text box used on most pages.

create_pdf(fig_list[, filename, ...])

Combine matplotlib figures into a pdf report and save file to disk.

dict_to_box(d, textprops[, vsep, hsep])

Arrange dictionary keys and values aligned in tabular format.

filename_from_string(s[, max_length])

Return string that is valid as a filename from given string s.

get_filename(filename, extension, folder)

Create & return Path to store figure.

get_rectangle_below(artist[, bottom, right, ...])

Like get_xy_below(), but returns rectangle (left, bottom, width, height) as required by fig.add_axes().

get_xy_below(artist[, vsep])

Given some artist, get the vertical position where the "next lower" element can be drawn, in figure fraction.

points_to_data(ax[, x_points, y_points])

Transform an offset value in points to data coordinates.

points_to_figfraction(fig[, x_points, y_points])

Transform a value in points to figure fraction coordinates in y direction.

prepare_figure([settings, width, height, ...])

Create default matplotlib figure in given dimensions, set backend, update rcParams, add footer.

set_footer(fig)

Add footer string and SunPeek small logo at bottom right of fig page.

set_page_number(fig, page_number[, n_pages])

Add page number at top right of fig page.

update_rcparams([target, font_family, font_size])

Update plot parameters, depending on plot target.

utc_str(d, tz[, format_spec])

Pretty-print a timezone-aware datetime to e.g. '2017-05-25 10:31 (UTC+1)'.

Classes

Colors(value[, names, module, qualname, ...])

Defaults(value[, names, module, qualname, ...])

PlotResult(figure, filename)

PlotSettings([target, with_interval_plots, ...])

Settings for PC Method plots & pdf report generation.

PlotTarget(value[, names, module, qualname, ...])

TableColumnFormat([header_str, unit_str, ...])