output_utilities#

Classes:

Figure_Lean(name, directory[, ...])

Wrapper class for figures.

MathTextSciFormatter([fmt])

Formatter for scientific notation in MathText.

Functions:

bottom_offset(self, bboxes, bboxes2)

Bottom offset for cost contribution plot labels.

dynamic_value_formatting(value[, cutoff])

Dynamic formatiing of value to string.

format_scientific(value)

Converts value to string with scientfic (10**x) notation

insert_image(path, x, y, zoom, ax)

Insert image into plot.

make_bold(string)

Convert provided string to a string which is formatted to be bold.

millify(n[, dollar_sign])

Converts n to a string with shorthand notation for thousand-steps

set_font(font_family, font, font_size)

Set font for plot.

class pyH2A.Utilities.output_utilities.Figure_Lean(name, directory, provided_figure_and_axis=None, show=False, save=False, pdf=True, dpi=300, transparent=False, nrows=1, ncols=1, fig_width=6.4, fig_height=4.8, left=0.125, right=0.9, top=0.88, bottom=0.11, wspace=0.2, hspace=0.2, font_family='sans-serif', font='Arial', font_size=12, sharex=False, input_file_name=None, append_file_name=True)[source]#

Wrapper class for figures.

Parameters
namestr

Name of figure, used for saving.

directorystr

Path to directory where figure is to be saved.

provided_figure_and_axistuple or None, optional

Tuple of matplotlib.fig and matplotlib.ax objects. If None new fig and ax objects are generated.

showbool, optional

If True, figure is shown.

savebool, optional

If True, figure is saved.

pdfbool, optional

If True, figure is saved as a PDF file. If False, it is saved as a PNG file.

dpiint, optional

Dots per inch resolution of figure.

transparentbool, optional

Flag to control if background of figure is transparent or not.

nrowsint, optional

Number of rows for subplots.

ncolsint, optional

Number of columns for suplots.

fig_widthfloat, optional

Width of figure in inches.

fig_heightfloat, optional

Height of figure in inches.

leftfloat, optional

Left edge of plot in axis fraction coordinates.

rightfloat, optional

Right edge of plot in axis fraction coordinates.

topfloat, optional

Top edge of plot in axis fraction coordinates.

bottomfloat, optional

Bottom edge of plot in axis fraction coordinates.

wspacefloat, optional

Vertical white space between subplots.

hspacefloat, optional

Horizontal white space between subplots.

font_familystr, optional

Font family, either ‘serif’ or ‘sans-serif’.

fontstr, optional

Name of font.

font_sizefloat, optional

Font size.

sharexbool, optional

Flag to control if x axis is shared between subplots.

input_file_namestr, optional

Name of input file.

append_file_name ; bool, optional

Flag to control if input_file_name is appended to file name of figure.

Notes

Provided figure is shown and/or saved in provided directory with given name by running Figure_Lean.execute().

Methods:

execute()

Running self.execute() executes desired show and save options.

save_figure(pdf, dpi, transparent)

Saving figure in target dictionary with specified parameters.

execute()[source]#

Running self.execute() executes desired show and save options.

save_figure(pdf, dpi, transparent)[source]#

Saving figure in target dictionary with specified parameters.

class pyH2A.Utilities.output_utilities.MathTextSciFormatter(fmt='%1.1e')[source]#

Formatter for scientific notation in MathText.

Methods

__call__:

Call method.

fix_minus:

Fixing minus.

format_data:

Format data method.

format_data_short:

Format data shortened method.

format_ticks:

Format ticks methods.

pyH2A.Utilities.output_utilities.bottom_offset(self, bboxes, bboxes2)[source]#

Bottom offset for cost contribution plot labels.

pyH2A.Utilities.output_utilities.dynamic_value_formatting(value, cutoff=6)[source]#

Dynamic formatiing of value to string.

Parameters
cutoffint, optional

Cutoff value for string length. Below cutoff value a string is shown without special formatting.

Notes

If value is an int (or a float that can be represented as an int) and its length as a string is less than the cutoff value, it will be printed as such. If its length as a string is more than the cutoff value, it will be either printed using the millify function (if the value is larger than 1), or using the format_scientific function (if the value is smaller than 1).

pyH2A.Utilities.output_utilities.format_scientific(value)[source]#

Converts value to string with scientfic (10**x) notation

pyH2A.Utilities.output_utilities.insert_image(path, x, y, zoom, ax)[source]#

Insert image into plot.

Parameters
pathstr

Path to image to be inserted.

xfloat

x axis coordinate of image in axis fraction coordinates.

yfloat

y axis coordinate of image in axis fraction coordinates.

axmatplotlib.ax

matplotlib.ax object into which image is inserted.

pyH2A.Utilities.output_utilities.make_bold(string)[source]#

Convert provided string to a string which is formatted to be bold. “%” signs cannot be rendered bold with this approach and are hence returned normal

pyH2A.Utilities.output_utilities.millify(n, dollar_sign=True)[source]#

Converts n to a string with shorthand notation for thousand-steps

pyH2A.Utilities.output_utilities.set_font(font_family, font, font_size)[source]#

Set font for plot.

Parameters
font_familystr

Font family, either ‘serif’ or ‘sans-serif’.

fontstr

Name of font.

font_sizefloat

Font size.