Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

MplDrawer

class MplDrawer[source]

Drawer for MatplotLib backend.

Options

The following can be set using set_options().

Options
  • Defined in the class BaseDrawer:

    • axis (Any)

      Default value: None
      Arbitrary object that can be used as a canvas.
    • subplots (Tuple[int, int])

      Default value: (1, 1)
      Number of rows and columns when the experimental result is drawn in the multiple windows.
    • default_style (PlotStyle)

      Default value: {"figsize": ("figsize", (8, 5)), "legend_loc": ("legend_loc", None), "tick_label_size": ("tick_label_size", 14), "axis_label_size": ("axis_label_size", 16), "textbox_rel_pos": ("textbox_rel_pos", (0.5, -0.25)), "textbox_text_size": ("textbox_text_size", 12), "errorbar_capsize": ("errorbar_capsize", 4), "symbol_size": ("symbol_size", 6.0)}
      The default style for drawer. This must contain all required style parameters for drawer, as is defined in PlotStyle.default_style(). Subclasses can add extra required style parameters by overriding _default_style().

Figure options

The following can be set using set_figure_options().

Options
  • Defined in the class BaseDrawer:

    • xlabel (Union[str, List[str]])

      Default value: None
      X-axis label string of the output figure. If there are multiple columns in the canvas, this could be a list of labels.
    • ylabel (Union[str, List[str]])

      Default value: None
      Y-axis label string of the output figure. If there are multiple rows in the canvas, this could be a list of labels.
    • xlim (Tuple[float, float])

      Default value: None
      Min and max value of the horizontal axis. If not provided, it is automatically scaled based on the input data points.
    • ylim (Tuple[float, float])

      Default value: None
      Min and max value of the vertical axis. If not provided, it is automatically scaled based on the input data points.
    • xval_unit (str)

      Default value: None
      Unit of x values. No scaling prefix is needed here as this is controlled by xval_unit_scale.
    • yval_unit (str)

      Default value: None
      Unit of y values. See xval_unit for details.
    • xval_unit_scale (bool)

      Default value: True
      Whether to add an SI unit prefix to xval_unit if needed. For example, when the x values represent time and xval_unit="s", xval_unit_scale=True adds an SI unit prefix to "s" based on X values of plotted data. In the output figure, the prefix is automatically selected based on the maximum value in this axis. If your x values are in [1e-3, 1e-4], they are displayed as [1 ms, 10 ms]. By default, this option is set to True. If False is provided, the axis numbers will be displayed in the scientific notation.
    • yval_unit_scale (bool)

      Default value: True
      Whether to add an SI unit prefix to yval_unit if needed. See xval_unit_scale for details.
    • figure_title (str)

      Default value: None
      Title of the figure. Defaults to None, i.e. nothing is shown.
    • series_params (Dict[str, Dict[str, Any]])

      Default value: {}
      A dictionary of parameters for each series. This is keyed on the name for each series. Sub-dictionary is expected to have the following three configurations, “canvas”, “color”, “symbol” and “label”; “canvas” is the integer index of axis (when multi-canvas plot is set), “color” is the color of the drawn graphics, “symbol” is the series marker style for scatter plots, and “label” is a user provided series label that appears in the legend.
    • custom_style (PlotStyle)

      Default value: {}
      The style definition to use when drawing. This overwrites style parameters in default_style in options. Defaults to an empty PlotStyle instance (i.e., PlotStyle()).

Initialization

Create a BaseDrawer instance.

Attributes

MplDrawer.DefaultColors

MplDrawer.DefaultMarkers

MplDrawer.figure

Return figure object handler to be saved in the database.

MplDrawer.figure_options

Return the figure options.

MplDrawer.options

Return the drawer options.

MplDrawer.style

The combined plot style for this drawer.

Methods

MplDrawer.config()

Return the config dictionary for this drawer.

MplDrawer.filled_x_area(x_ub, x_lb, y_data)

Draw filled area as a function of y-values.

MplDrawer.filled_y_area(x_data, y_ub, y_lb)

Draw filled area as a function of x-values.

MplDrawer.format_canvas()

Final cleanup for the canvas appearance.

MplDrawer.image(data[, extent, name, label, ...])

Draw an image of numerical values, series names, or RGB/A values.

MplDrawer.initialize_canvas()

Initialize the drawer canvas.

MplDrawer.label_for(name, label)

Get the legend label for the given series, with optional overrides.

MplDrawer.line(x_data, y_data[, name, ...])

Draw a line.

MplDrawer.scatter(x_data, y_data[, x_err, ...])

Draw scatter points, with optional error-bars.

MplDrawer.set_figure_options(**fields)

Set the figure options.

MplDrawer.set_options(**fields)

Set the drawer options.

MplDrawer.textbox(description[, rel_pos])

Draw text box.