pygsti.report.generate_boxplot¶
-
pygsti.report.
generate_boxplot
(xvals, yvals, xyGateStringDict, subMxs, cmapFactory, xlabel='', ylabel='', scale=1.0, prec=0, title='sub-mx', sumUp=False, boxLabels=True, histogram=False, histBins=50, save_to=None, ticSize=20, invert=False, inner_x_labels=None, inner_y_labels=None, inner_x_label=None, inner_y_label=None, grid=False)¶ Creates a view of nested box plot data (i.e. a matrix for each (x,y) pair).
Given lists of x and y values, a dictionary to convert (x,y) pairs into gate strings, and a function to convert a “base” gate string into a matrix of floating point values, this function computes (x,y) => matrix data and displays it in one of two ways:
- As a full nested color box plot, showing all the matrix values individually
- As a color box plot containing the sum of the elements in the (x,y) matrix as the (x,y) box.
A histogram of the values can also be computed and displayed.
Parameters: - yvals (xvals,) – List of x and y values. Elements can be any hashable quantity, and will be converted into x and y tic labels. Tuples of strings are converted specially for nice latex rendering of gate strings.
- xyGateStringDict (dict) – Dictionary with keys == (x_value,y_value) tuples and values == gate strings, where a gate string can either be a GateString object or a tuple of gate labels. Provides the mapping between x,y pairs and gate strings. None values are allowed, and indicate that there is not data for that x,y pair and nothing should be plotted.
- subMxs (list) – A list of lists of 2D numpy.ndarrays. subMxs[iy][ix] specifies the matrix of values or sum (if sumUp == True) displayed in iy-th row and ix-th column of the plot. NaNs indicate elements should not be displayed.
- cmapFactory (instance of the ColormapFactory class) –
- ylabel (xlabel,) – X and Y axis labels
- scale (float, optional) – Scaling factor to adjust the size of the final figure.
- prec (int, optional) – Precision for box labels. Allowed values are: ‘compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int
- title (string, optional) – Plot title (latex can be used)
- sumUp (bool, optional) – False displays each matrix element as it’s own color box True sums the elements of each (x,y) matrix and displays a single color box for the sum.
- boxLabels (bool, optional) – Whether box labels are displayed. It takes much longer to generate the figure when this is set to True.
- histogram (bool, optional) – Whether a histogram of the matrix element values or summed matrix values (depending on sumUp) should also be computed and displayed.
- histBins (int, optional) – The number of bins to use in the histogram.
- save_to (str, optional) – save figure to this filename (usually ending in .pdf)
- ticSize (int, optional) – size of tic marks
- invert (bool, optional) – If True, invert the nesting order of the nested color box plot (applicable only when sumUp == False). Use inner_x_labels and inner_y_labels to label the x and y axes.
- inner_y_labels (inner_x_labels,) – Similar to xvals, yvals but labels for the columns and rows of the (x,y) matrices computed by subMxCreationFn. Used when invert == True.
- grid (bool, optional) – Whether or not grid lines should be displayed.
Returns: rptFig – The encapsulated matplotlib figure that was generated. Note that figure extra info is a dict with keys:
- nUsedXs : int
The number of used X-values, proportional to the overall final figure width
- nUsedYs : int
The number of used Y-values, proportional to the overall final figure height
Return type: ReportFigure