pygsti.report.mpl_colormaps
Plotly-to-Matplotlib conversion functions.
Module Contents
Classes
Matplotlib version of lin-log colormap normalization |
Functions
|
Create a linear matplotlib normalization |
|
Make a color map that simply linearly interpolates between a set of colors in RGB space. |
|
Determinining function for whether text should be white or black |
|
Process a (plotly-compatible) text label lbl to matplotlb text. |
|
Process a list of plotly labels into matplotlib ones |
|
Convert a plotly color name to a matplotlib compatible one. |
|
Convert a pygsti (plotly) figure to a matplotlib figure. |
|
Create a plot showing the layout of a single sub-block of a goodness-of-fit box plot. |
- class pygsti.report.mpl_colormaps.MplLinLogNorm(linlog_colormap, clip=False)
Bases:
matplotlib.colors.Normalize
Matplotlib version of lin-log colormap normalization
Parameters
- linlog_colormapLinlogColormap
pyGSTi linear-logarithmic color map to base this colormap off of.
- clipbool, optional
Whether clipping should be performed. See
matplotlib.colors.Normalize
.
- trans
- cm
- pygsti.report.mpl_colormaps.mpl_make_linear_norm(vmin, vmax, clip=False)
Create a linear matplotlib normalization
Parameters
- vminfloat
Minimum mapped color value.
- vmaxfloat
Maximum mapped color value.
- clipbool, optional
Whether clipping should be performed. See
matplotlib.colors.Normalize
.
Returns
matplotlib.colors.Normalize
- pygsti.report.mpl_colormaps.mpl_make_linear_cmap(rgb_colors, name=None)
Make a color map that simply linearly interpolates between a set of colors in RGB space.
Parameters
- rgb_colorslist
Each element is a (value, (r, g, b)) tuple specifying a value and an RGB color. Both value and r, g, and b should be floating point numbers between 0 and 1.
- namestring, optional
A name for the colormap. If not provided, a name will be constructed from an random integer.
Returns
cmap
- pygsti.report.mpl_colormaps.mpl_besttxtcolor(x, cmap, norm)
Determinining function for whether text should be white or black
Parameters
- xfloat
Value of the cell in question
- cmapmatplotlib colormap
Colormap assigning colors to the cells
- normmatplotlib normalizer
Function to map cell values to the interval [0, 1] for use by a colormap
Returns
{“white”,”black”}
- pygsti.report.mpl_colormaps.mpl_process_lbl(lbl, math=False)
Process a (plotly-compatible) text label lbl to matplotlb text.
Parameters
- lblstr
A text label to process.
- mathbool, optional
Whether math-formatting (latex) should be used.
Returns
str
- pygsti.report.mpl_colormaps.mpl_process_lbls(lbl_list)
Process a list of plotly labels into matplotlib ones
Parameters
- lbl_listlist
A list of string-valued labels to process.
Returns
- list
the processed labels (strings).
- pygsti.report.mpl_colormaps.mpl_color(plotly_color)
Convert a plotly color name to a matplotlib compatible one.
Parameters
- plotly_colorstr
A plotly color value, e.g. “#FF0023” or “rgb(0,255,128)”.
Returns
str
- pygsti.report.mpl_colormaps.plotly_to_matplotlib(pygsti_fig, save_to=None, fontsize=12, prec='compacthp', box_labels_font_size=6)
Convert a pygsti (plotly) figure to a matplotlib figure.
Parameters
- pygsti_figReportFigure
A pyGSTi figure.
- save_tostr
Output filename. Extension determines type. If None, then the matplotlib figure is returned instead of saved.
- fontsizeint, optional
Base fontsize to use for converted figure.
- precint or {“compact”,”compacth”}
Digits of precision to include in labels.
- box_labels_font_sizeint, optional
The size for labels on the boxes. If 0 then no labels are put on the boxes
Returns
- matplotlib.Figure
Matplotlib figure, unless save_to is not None, in which case the figure is closed and None is returned.
- pygsti.report.mpl_colormaps.special_keyplot(pygsti_fig, save_to, fontsize)
Create a plot showing the layout of a single sub-block of a goodness-of-fit box plot.
Parameters
- pygsti_figReportFigure
The pyGSTi figure to process.
- save_tostr
Filename to save to.
- fontsizeint
Fone size to use
Returns
matplotlib.Figure