aim2dat.plots.simple_plot

Test plots for the base plot class (will be removed at a later stage).

Module Contents

Classes

SimplePlot

Direct and flexible interface to the backend plot libraries.

class aim2dat.plots.simple_plot.SimplePlot(**kwargs)[source]

Bases: aim2dat.plots.base_plot._BasePlot, aim2dat.plots.base_mixin._HLineMixin, aim2dat.plots.base_mixin._VLineMixin

Direct and flexible interface to the backend plot libraries.

Overview

Properties

backend

used backend library to plot the data. Supported values are "matplotlib" and

custom_alpha

Alpha value(s) controlling the opacity of plot elements.

custom_colors

Colors used in the plot.

custom_hatch

Hatch value(s) controlling the hatch of plot elements.

custom_linestyles

Line styles used in the plot (This feature is not supported by all plot

custom_linewidths

Line widths used in the plot (This feature is not supported by all plot

custom_markers

Marker types used in the plot (This feature is not supported by all plot

custom_xticklabels

List of labels for the ticks on the x-axis.

custom_xticks

List of values to set ticks on the x-axis.

custom_yticklabels

List of labels for the ticks on the y-axis.

custom_yticks

List of values to set ticks on the y-axis.

data_labels

List of labels for all data sets.

equal_aspect_ratio

Set equal aspect ratio of the plot(s).

legend_bbox_to_anchor

Shift between box and anchor. The default value is (1, 1).

legend_loc

Location of the legend. The default value is 1.

legend_ncol

Columns of the legend (only supported for the matplotlib backend).

legend_sort_entries

Sort entries of the legend.

plot_grid

Whether to draw a grid in the plot. The default value is False.

ratio

Length-to-width ratio of the plot given as a tuple of two numbers.

show_colorbar

Show colorbar (not supported by all plots).

show_grid

Whether to draw a grid in the plot. The default value is False.

show_legend

Show legend. The default value is False.

show_plot

Show plot. The default value is False.

store_path

Path of the folder to store the plot. The default value is ./.

store_plot

Store plot. The default value is False.

style_sheet

Custom matplotlib style sheet.

subplot_adjust

Keyword arguments for the matplotlib subplots_adjust function.

subplot_align_ylabels

Align y label of plot. The default value is False.

subplot_gridspec

Grid spec values.

subplot_hspace

Vertical spacing between the subplots.

subplot_ncols

Number of columns. The default value is 1.

subplot_nrows

Number of rows. The default value is 2.

subplot_share_colorbar

Use one common colorbar for all subplots.

subplot_share_legend

Merge legend items of all subplots.

subplot_sharex

Share the x-axis of subplots located in the same column.

subplot_sharey

Share the y-axis of subplots located in the same row.

subplot_sup_title

Title of the whole figure.

subplot_sup_x_label

x-label of the whole figure.

subplot_sup_y_label

y-label of the whole figure.

subplot_tight_layout

Tight layout of plot. The default value is False.

subplot_wspace

Horizontal spacing between the subplots.

x_label

Label of the x-axis. If None is given no label will be shown. The

x_range

Range of the x-axis. The default value is None.

y_label

Label of the y-axis. If None is given no label will be shown. The

y_range

Range of the y-axis. The default value is None.

Methods

add_hline(y, x_min, x_max, color, line_style, scaled, foreground, subplot_assignment, data_label)

Add a vertical line to the plot.

add_vline(x, y_min, y_max, color, line_style, scaled, foreground, subplot_assignment, data_label)

Add a vertical line to the plot.

auto_set_axis_properties(set_x_label, set_y_label)

Whether the axis labels and other axis properties are auto-generated.

create_default_gridspec(nrows, ncols, nplots, heights, widths, center_last_row)

Create default grid for multiple plots.

import_bar_data_set(data_label, x_values, y_values, heights, plot_label, color, hatch, alpha, bottom, width, align)

Import data set for a bar plot.

import_scatter_data_set(data_label, x_values, y_values, y_values_2, plot_label, color, face_color, alpha, line_style, line_width, marker, marker_face_color, marker_edge_width, use_fill, use_fill_between)

Import data set for a scatter plot.

plot(data_labels, plot_title, plot_name, subplot_assignment)

Plot the data sets.

remove_additional_plot_elements()

Remove all added plot elements.

reset_gridspec()

Reset gridspec settings.

return_data_labels()

Return the labels of all data sets.

property backend

used backend library to plot the data. Supported values are "matplotlib" and "plotly".

Type:

str

property custom_alpha

Alpha value(s) controlling the opacity of plot elements.

Type:

float, list or tuple

property custom_colors

Colors used in the plot.

Type:

list or tuple

property custom_hatch

Hatch value(s) controlling the hatch of plot elements.

Type:

float, list or tuple

property custom_linestyles

Line styles used in the plot (This feature is not supported by all plot types).

Type:

list or tuple

property custom_linewidths

Line widths used in the plot (This feature is not supported by all plot types).

Type:

list or tuple

property custom_markers

Marker types used in the plot (This feature is not supported by all plot types).

Type:

list or tuple

property custom_xticklabels

List of labels for the ticks on the x-axis.

Type:

list

property custom_xticks

List of values to set ticks on the x-axis.

Type:

list

property custom_yticklabels

List of labels for the ticks on the y-axis.

Type:

list

property custom_yticks

List of values to set ticks on the y-axis.

Type:

list

property data_labels

List of labels for all data sets.

Type:

list

property equal_aspect_ratio

Set equal aspect ratio of the plot(s).

Type:

bool

property legend_bbox_to_anchor

Shift between box and anchor. The default value is (1, 1).

Type:

tuple or list

property legend_loc

Location of the legend. The default value is 1.

Type:

int

property legend_ncol

Columns of the legend (only supported for the matplotlib backend).

Type:

int

property legend_sort_entries

Sort entries of the legend.

Type:

bool

property plot_grid

Whether to draw a grid in the plot. The default value is False.

Type:

bool

property ratio

Length-to-width ratio of the plot given as a tuple of two numbers.

Type:

tuple or list

property show_colorbar

Show colorbar (not supported by all plots).

Type:

bool

property show_grid

Whether to draw a grid in the plot. The default value is False.

Type:

bool

property show_legend

Show legend. The default value is False.

Type:

bool

property show_plot

Show plot. The default value is False.

Type:

bool

property store_path

Path of the folder to store the plot. The default value is ./.

Type:

str

property store_plot

Store plot. The default value is False.

Type:

bool

property style_sheet

Custom matplotlib style sheet.

Type:

str

property subplot_adjust

Keyword arguments for the matplotlib subplots_adjust function.

Type:

dict

property subplot_align_ylabels

Align y label of plot. The default value is False.

Type:

bool

property subplot_gridspec

Grid spec values.

Type:

list or tuple

property subplot_hspace

Vertical spacing between the subplots.

Type:

float

property subplot_ncols

Number of columns. The default value is 1.

Type:

int

property subplot_nrows

Number of rows. The default value is 2.

Type:

int

property subplot_share_colorbar

Use one common colorbar for all subplots.

Type:

bool

property subplot_share_legend

Merge legend items of all subplots.

Type:

bool

property subplot_sharex

Share the x-axis of subplots located in the same column.

Type:

bool

property subplot_sharey

Share the y-axis of subplots located in the same row.

Type:

bool

property subplot_sup_title

Title of the whole figure.

Type:

str

property subplot_sup_x_label

x-label of the whole figure.

Type:

str

property subplot_sup_y_label

y-label of the whole figure.

Type:

str

property subplot_tight_layout

Tight layout of plot. The default value is False.

Type:

bool

property subplot_wspace

Horizontal spacing between the subplots.

Type:

float

property x_label

Label of the x-axis. If None is given no label will be shown. The default value is None.

Type:

str or None

property x_range

Range of the x-axis. The default value is None.

Type:

tuple or list

property y_label

Label of the y-axis. If None is given no label will be shown. The default value is None.

Type:

str or None

property y_range

Range of the y-axis. The default value is None.

Type:

tuple or list

add_hline(y, x_min, x_max, color=None, line_style=None, scaled=False, foreground=False, subplot_assignment=None, data_label=None)

Add a vertical line to the plot.

Parameters:
  • y (float) – y-position of the line.

  • x_min (float) – Bottom x-position of the line.

  • x_max (float) – Top x-position of the line.

  • color (str or None) – Color of the line.

  • line_style (str or None) – Line style of the line.

  • scaled (bool) – Whether the input is given in scaled positions.

  • foreground (bool) – Whether to plot the line in front of the other elements.

  • subplot_assignment (list or None) – Assignment of the line to individual subplots.

add_vline(x, y_min, y_max, color=None, line_style=None, scaled=False, foreground=False, subplot_assignment=None, data_label=None)

Add a vertical line to the plot.

Parameters:
  • x (float) – x-position of the line.

  • y_min (float) – Bottom y-position of the line.

  • y_max (float) – Top y-position of the line.

  • color (str or None) – Color of the line.

  • line_style (str or None) – Line style of the line.

  • scaled (bool) – Whether the input is given in scaled positions.

  • foreground (bool) – Whether to plot the line in front of the other elements.

  • subplot_assignment (list or None) – Assignment of the line to individual subplots.

auto_set_axis_properties(set_x_label=True, set_y_label=True)

Whether the axis labels and other axis properties are auto-generated.

Parameters:
  • set_x_label (bool) – Set x-axis label automatically.

  • set_y_label (bool) – Set y-axis label automatically.

create_default_gridspec(nrows, ncols, nplots, heights=1, widths=1, center_last_row=True)

Create default grid for multiple plots.

Parameters:
  • nrows (Int) – Number of rows.

  • ncols (int) – Number columns.

  • nplots (int) – Number of subplots.

  • heights (int (optional)) – Height of subplots.

  • widths (int (optional)) – Width of subplots.

  • center_last_row (bool (optional)) – Center the plots of the last row.

import_bar_data_set(data_label, x_values, y_values, heights, plot_label=None, color=None, hatch=None, alpha=None, bottom=0.0, width=0.8, align='center')[source]

Import data set for a bar plot.

Parameters:
  • data_label (str) – Internal label of the data set.

  • x_values (list) – List of x-values of the points.

  • y_values (list) – List of y-values of the points.

  • heights (list) – List of bar heights.

  • plot_label (str (optional)) – Label of the data set shown in the legend.

  • color (str (optional)) – Color of the data set.

  • hatch (str (optional)) – Hatch of the data set.

  • alpha (float (optional)) – Transparency of the data set.

  • bottom (float) – Position of the bottom of the bars.

  • width (float) – Width of the bars.

  • align (str) – Alignment of the bar.

import_scatter_data_set(data_label, x_values, y_values, y_values_2=None, plot_label=None, color=None, face_color=None, alpha=None, line_style=None, line_width=None, marker=None, marker_face_color=None, marker_edge_width=None, use_fill=False, use_fill_between=False)[source]

Import data set for a scatter plot.

Parameters:
  • data_label (str) – Internal label of the data set.

  • x_values (list) – List of x-values of the points.

  • y_values (list) – List of y-values of the points.

  • y_values_2 (list) – Second list of y-values to be used with use_fill_between.

  • plot_label (str (optional)) – Label of the data set shown in the legend.

  • color (str (optional)) – Color of the data set.

  • face_color (str (optional)) – Face color of the data set.

  • alpha (float (optional)) – Transparency of the data set.

  • line_style (str (optional)) – Line style of the data set.

  • line_width (int or float) – Line width of the data set.

  • marker (str (optional)) – Marker shape.

  • marker_face_color (str (optional)) – Marker face color.

  • marker_edge_width (int (optional)) – Marker size.

  • use_fill (bool (optional)) – Whether to fill the area between the x-axis and the data points.

  • use_fill_between (bool (optional)) – Whether to fill the area between the deta sets.

plot(data_labels, plot_title=None, plot_name='plot.png', subplot_assignment=None)

Plot the data sets.

Parameters:
  • data_labels (list or str) – List of data labels of the data sets that are plotted or in case only one data set is plotted a string.

  • plot_title (list or str (optional)) – Title of the plots or subplots.

  • plot_name (str (optional)) – The file name of the plot.

  • subplot_assignment (list or None (optional)) – Assignment of the data sets to individual subplots.

Returns:

fig (matplotlib.pyplot.figure or plotly.graph_objects.Figure) – Figure object of the plot.

remove_additional_plot_elements()

Remove all added plot elements.

reset_gridspec()

Reset gridspec settings.

return_data_labels()

Return the labels of all data sets.

Returns:

data_labels (list) – List of the labels of all data sets.