slitflow.fig.style module

class Basic(info_path=None)[source]

Bases: Figure

Basic figure style for A4 paper size.

This class is valid only if there is only one axes in Figure. This class is used to change matplotlib’s figure format in a convenient way. The default setting is to create a quarter-width square graphic image on an A4 size document.

Parameters:
  • reqs[0] (Figure) – Figure class object.

  • param["size"] (list of float, optional) – [width, height] of figure image (cm). Defaults to [4.5, 4.5].

  • param["margin"] (list of float, optional) – [left, bottom, right, top] of figure margin (cm). Defaults to [0.9, 0.6, 0.1, 0.4].

  • param["limit"] (list of float, optional) – [x_lower, x_upper, y_lower, y_upper] limits of figure. If x_lower = None, skip X limits.

  • param["tick"] (list of list of float, optional) – Tick position float lists for X and Y axes. numpy.ndarray is available, e.g., [np.arange(0, 1, 0.1), [0, 1, 2]].

  • param["tick_label"] (list of list of str, optional) – Tick label for [x-axis, y-axis].

  • param["format"] (list of str, optional) – Strings for X and tick formats, e.g. [“%.0f”,”%.1f”].

  • param["is_box"] (bool, optional) – Draw box lined axis, if True.

  • param["line_widths"] (float or list of float, optional) – Line width. Defaults to 1.

  • param["line_styles"] (str or list of str, optional) – Line style.

  • param["line_colors"] (list of RGB 0-255, optional) – Line color. e.g., [[0, 0, 255]] is blue. Palette name is also available.

  • param["error_thicknesses"] (list of float, optional) – Error bar line width. Defaults to 1.

  • param["error_line_styles"] (list of str, optional) – Error bar line style.

  • param["error_cap_sizes"] (list of float, optional) – Error bar cap line width.

  • param["marker_styles"] (str or list of str, optional) – Marker style.

  • param["marker_colors"] (list of list of RGB 0-255, optional) – Marker edge and face colors. e.g., [[[0,0,0]],[[100,100,100]]]. List of palette_name is also available.

  • param["marker_widths"] (float or list of float, optional) – Marker widths.

  • param["marker_sizes"] (float or list of float, optional) – Marker sizes.

  • param["bar_widths"] (float or list of float) – Width of each bar.

  • param["label"] (list of str, optional) – [X label string, Y label string] for axes label texts.

  • param["legend"] (list, optional) – [list of label strings, handle indexes of artists to create a legend, keyword arguments for matplotlib legend]. If [None, None], then delete all legends. If handle indexes are None, e.g. [[“Label1”, “Label2”], None] then create legend for all artists. If only handle indexes are specified, e.g. [None, [0,1]], then create legend for selected artists with existing labels. Keyword arguments should be dictionary, e.g. {“loc”: “center”}.

  • param["log_scale"] (list of bool) – Change axes to the log scale. e.g., [False, True] means that the only y-axis is the log scale.

  • param["title"] (str, optional) – String for the figure title.

  • param["clim"] (list of float, optional) – [vmin, vmax] of colormap limit.

  • param["cmap"] (str, optional) – Colormap name. See also matplotlib.colormaps.

Returns:

Styled Figure object

Return type:

Figure

save_data(data, path)[source]

matplotlib.pyplot.clf() is removed to avoid deleting the final matplotlib.figure.Figure object.

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Basic figure style for A4 paper size.

Parameters:
Returns:

Styled Figure object

Return type:

matplotlib.figure.Figure

class ParamTable(info_path=None)[source]

Bases: Basic

Set figure style from the parameter table.

The parameter dictionary of Basic is replaced as Table to set different style values for split figures.

Parameters:
  • reqs[0] (Figure) – Figure class object.

  • reqs[1] (Table) – Parameter table object. For required columns, please see Basic.

  • param (dict) – Parameters for Basic is available to set common style for all figures.

Returns:

Styled Figure object

Return type:

Figure

set_reqs(reqs=None, param=None)[source]

Drop elements that exist only in one required data.

static process(reqs, param)[source]

Basic figure style for A4 paper size.

Parameters:
Returns:

Styled Figure object

Return type:

matplotlib.figure.Figure

class ColorBar(info_path=None)[source]

Bases: Figure

Create color bar figure from mappable figure object.

Parameters:
  • reqs[0] (Figure) – Figure containing mappable object.

  • param["size"] (list of float, optional) – [width, height] of figure image (cm). Defaults to [4.5, 0.9].

  • param["margin"] (list, optional) – [Left, bottom, right, top] of figure margin (cm). Defaults to [0.2, 0.7, 0.2, 0.05].

  • param["is_vertical"] (bool, optional) – Whether colorbar orientation is vertical. Defaults to False.

  • param["label"] (str, optional) – Colorbar label string.

  • param["tick"] (list of float, optional) – List of colorbar tick values.

  • param["format"] (str, optional) – Tick value format string. e.g. “%.0f”.

Returns:

Styled colorbar Figure object

Return type:

Figure

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Create color bar figure from mappable figure object.

Parameters:
Returns:

Styled Figure object

Return type:

matplotlib.figure.Figure

set_format(fig, axes_no=0)[source]

Initiate figure format.

set_size(fig, size, margin, axes_no=0)[source]

Set figure size based on centimeter scale.

set_legend(fig, labels=None, handle_indexes=None, kwargs={}, axes_no=0)[source]

Set figure legend.

Parameters:
Returns:

Figure object with legend

Return type:

matplotlib.figure.Figure

Caution

All artists to be candidates for the legend should have labels during their creation.

set_title(fig, title, axes_no=0)[source]

Set title.

set_lim(fig, x_lim=None, y_lim=None, axes_no=0)[source]

Set limit without changing tick and format.

set_tickformat(fig, x_format, y_format, axes_no=0)[source]

Set tick format without changing the style.

set_tick(fig, x_tick=None, y_tick=None, axes_no=0)[source]

Set ticks without changing limits.

set_label(fig, x_label, y_label, axes_no=0)[source]

Set axis labels without changing its font.

set_ticklabel(fig, x_label, y_label, axes_no=0)[source]

Set tick labels without changing its font.

set_linewidth(fig, line_widths, axes_no=0)[source]

Set widths of lines.

Parameters:
  • fig (matplotlib.figure.Figure) – Figure containing line artists.

  • line_widths (float or list of float) – Resizes line widths. All lines are resized according to the same value if set as a float.

Returns:

Restyled Figure object

Return type:

matplotlib.figure.Figure

set_linestyle(fig, line_styles, axes_no=0)[source]

Change line styles in bulk or individually.

set_linecolor(fig, line_colors, axes_no=0)[source]

Set colors of all line artists.

Parameters:
Returns:

Restyled Figure object

Return type:

matplotlib.figure.Figure

set_markerstyle(fig, marker_styles, axes_no=0)[source]

Change line styles in bulk or individually.

Caution

Scatter plots can not change marker style.

set_markersize(fig, marker_sizes, axes_no=0)[source]

Set marker sizes of all artists.

set_markerwidth(fig, marker_widths, axes_no=0)[source]

Set marker widths of all artists.

set_barwidth(fig, bar_widths, axes_no=0)[source]

Set bar widths.

set_markercolor(fig, edge_colors, face_colors, axes_no=0)[source]

Set edge and face colors of all artists.

set_errorthickness(fig, error_thicknesses, axes_no=0)[source]

Set widths of lines.

Parameters:
  • fig (matplotlib.figure.Figure) – Figure containing line artists.

  • line_widths (float or list of float) – Resizes line widths. All lines are resized according to the same value if set as a float.

Returns:

Restyled Figure object

Return type:

matplotlib.figure.Figure

set_errorlinestyle(fig, error_line_styles, axes_no=0)[source]

Change error line styles in bulk or individually.

set_errorcolor(fig, error_colors, axes_no=0)[source]

Set colors of all line artists.

Parameters:
Returns:

Restyled Figure object

Return type:

matplotlib.figure.Figure

set_errorcapsize(fig, error_cap_sizes, axes_no=0)[source]

Set marker sizes of all artists.

is_boxed(fig, bool=True, axes_no=0)[source]

Show a rectangle-shaped box if True. Delete axes lines if False.

is_log_scale(fig, bools, axes_no=0)[source]

Change X and Y axes to the log scale.

Parameters:
  • fig (matplotlib.figure.Figure) – Figure object.

  • bools (list or bool) – Change axes to the log scale. e.g., [False, True] means that the only y-axis is the log scale.

Returns:

Restyled Figure object

Return type:

matplotlib.figure.Figure

set_cmap(fig, cmap, axes_no=0)[source]

Set cmaps of all artists.

rgb2cmap(rgb)[source]
set_clim(fig, vmin, vmax, axes_no=0)[source]

Set clim of all artists.