BaseCurveDrawer#

class BaseCurveDrawer[source]#

Abstract class for the serializable Qiskit Experiments curve drawer.

A curve drawer may be implemented by different drawing backends such as matplotlib or plotly. Sub-classes that wrap these backends by subclassing BaseCurveDrawer must implement the following abstract methods.

initialize_canvas

This method should implement a protocol to initialize a drawing canvas with user input axis object. Note that curve analysis drawer supports visualization of experiment results in multiple canvases tiled into N (row) x M (column) inset grids, which is specified in the option subplots. By default, this is N=1, M=1 and thus no inset grid will be initialized. The data points to draw might be provided with a canvas number defined in SeriesDef.canvas which defaults to None, i.e. no-inset grids.

This method should first check the drawing options for the axis object and initialize the axis only when it is not provided by the options. Once axis is initialized, this is set to the instance member self._axis.

format_canvas

This method should implement a protocol to format the appearance of canvas. Typically, it updates axis and tick labels. Note that the axis SI unit may be specified in the drawing options. In this case, axis numbers should be auto-scaled with the unit prefix.

draw_raw_data

This method is called after data processing is completed. This method draws raw experiment data points on the canvas.

draw_formatted_data

This method is called after data formatting is completed. The formatted data might be averaged over the same x values, or smoothed by a filtering algorithm, depending on how analysis class is implemented. This method is called with error bars of y values and the name of the curve.

draw_fit_line

This method is called after fitting is completed and when there is valid fit outcome. This method is called with the interpolated x and y values.

draw_confidence_interval

This method is called after fitting is completed and when there is valid fit outcome. This method is called with the interpolated x and a pair of y values that represent the upper and lower bound within certain confidence interval. This might be called multiple times with different interval sizes.

draw_fit_report

This method is called after fitting is completed and when there is valid fit outcome. This method is called with the list of analysis results and the reduced chi-squared values. The fit report should be generated to show this information on the canvas.

Deprecated since version 0.5: The class qiskit_experiments.curve_analysis.visualization.base_drawer.BaseCurveDrawer is deprecated as of qiskit-experiments 0.5. It will be removed after 0.6. Plotting and drawing functionality has been moved to the new qiskit_experiments.visualization module.

Attributes

figure#

Return figure object handler to be saved in the database.

options#

Return the drawing options.

Methods

config()[source]#

Return the config dictionary for this drawing.

Return type:

Dict

abstract draw_confidence_interval(x_data, y_ub, y_lb, name=None, **options)[source]#

Draw confidence interval.

Parameters:
  • x_data (Sequence[float]) – X values.

  • y_ub (Sequence[float]) – The upper boundary of Y values.

  • y_lb (Sequence[float]) – The lower boundary of Y values.

  • name (str | None) – Name of this curve.

  • options – Valid options for the drawer backend API.

abstract draw_fit_line(x_data, y_data, name=None, **options)[source]#

Draw fit line.

Parameters:
  • x_data (Sequence[float]) – X values.

  • y_data (Sequence[float]) – Fit Y values.

  • name (str | None) – Name of this curve.

  • options – Valid options for the drawer backend API.

abstract draw_fit_report(description, **options)[source]#

Draw text box that shows fit reports.

Parameters:
  • description (str) – A string to describe the fiting outcome.

  • options – Valid options for the drawer backend API.

abstract draw_formatted_data(x_data, y_data, y_err_data, name=None, **options)[source]#

Draw the formatted data that is used for fitting.

Parameters:
  • x_data (Sequence[float]) – X values.

  • y_data (Sequence[float]) – Y values.

  • y_err_data (Sequence[float]) – Standard deviation of Y values.

  • name (str | None) – Name of this curve.

  • options – Valid options for the drawer backend API.

abstract draw_raw_data(x_data, y_data, name=None, **options)[source]#

Draw raw data.

Parameters:
  • x_data (Sequence[float]) – X values.

  • y_data (Sequence[float]) – Y values.

  • name (str | None) – Name of this curve.

  • options – Valid options for the drawer backend API.

abstract format_canvas()[source]#

Final cleanup for the canvas appearance.

abstract initialize_canvas()[source]#

Initialize the drawing canvas.

set_options(**fields)[source]#

Set the drawing options. :param fields: The fields to update the options