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:NoneArbitrary 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 fordrawer, as is defined inPlotStyle.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:NoneX-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:NoneY-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:NoneMin 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:NoneMin 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:NoneUnit of x values. No scaling prefix is needed here as this is controlled byxval_unit_scale.yval_unit (str)
Default value:NoneUnit of y values. Seexval_unitfor details.xval_unit_scale (bool)
Default value:TrueWhether to add an SI unit prefix toxval_unitif needed. For example, when the x values represent time andxval_unit="s",xval_unit_scale=Trueadds 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 toTrue. IfFalseis provided, the axis numbers will be displayed in the scientific notation.yval_unit_scale (bool)
Default value:TrueWhether to add an SI unit prefix toyval_unitif needed. Seexval_unit_scalefor details.figure_title (str)
Default value:NoneTitle 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 indefault_styleinoptions. Defaults to an empty PlotStyle instance (i.e.,PlotStyle()).
Initialization
Create a BaseDrawer instance.
Attributes
Return figure object handler to be saved in the database.
Return the figure options.
Return the drawer options.
The combined plot style for this drawer.
Methods
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.
Final cleanup for the canvas appearance.
MplDrawer.image(data[, extent, name, label, ...])Draw an image of numerical values, series names, or RGB/A values.
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.