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.
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 optionsubplots
. 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 inSeriesDef.canvas
which defaults toNone
, 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.
Attributes
Return figure object handler to be saved in the database.
Return the drawing options.
Methods
Return the config dictionary for this drawing.
Draw cofidence interval.
BaseCurveDrawer.draw_fit_line
(x_data, y_data)Draw fit line.
BaseCurveDrawer.draw_fit_report
(description, ...)Draw text box that shows fit reports.
BaseCurveDrawer.draw_formatted_data
(x_data, ...)Draw the formatted data that is used for fitting.
BaseCurveDrawer.draw_raw_data
(x_data, y_data)Draw raw data.
Final cleanup for the canvas appearance.
Initialize the drawing canvas.
BaseCurveDrawer.set_options
(**fields)Set the drawing options.