pygsti.report.colormaps
Colormap and derived class definitions
Module Contents
Classes
A color map which encapsulates a plotly colorscale with a normalization. |
|
Colormap which combines a linear grayscale portion with a logarithmic color (by default red) portion. |
|
A diverging color map |
|
A sequential color map |
|
A piecewise-linear color map |
Functions
|
Convert a color string, such as "rgb(0,255,128)" or "#00FF88" to a numpy array of length 3. |
|
Evaluates plotly colorscale at a particular value. |
- pygsti.report.colormaps.to_rgb_array(color_str)
Convert a color string, such as “rgb(0,255,128)” or “#00FF88” to a numpy array of length 3.
Parameters
- color_strstr
A color string, e.g. “rgb(0,255,128)” or “#00FF88”.
Returns
numpy.ndarray
- pygsti.report.colormaps.interpolate_plotly_colorscale(plotly_colorscale, normalized_value)
Evaluates plotly colorscale at a particular value.
This function linearly interpolates between the colors of a Plotly colorscale.
Parameters
- plotly_colorscalelist
A Plotly colorscale (list of [val, color]) elements where val is a float between 0 and 1, and color is any acceptable Plotly color value (e.g. rgb(0,100,255), #0033FF, etc.).
- normalized_valuefloat
The value (between 0 and 1) to compute the color for.
Returns
- str
A string representation of the plotly color of the form “rgb(R,G,B)”.
- class pygsti.report.colormaps.Colormap(rgb_colors, hmin, hmax, invalid_color=None)
Bases:
object
A color map which encapsulates a plotly colorscale with a normalization.
This class also contains additional functionality such as the ability to compute the color corresponding to a particular value and extract matplotlib colormap and normalization objects.
Parameters
- rgb_colorslist
A list of [val, (R,G,B)] elements where val is a floating point number between 0 and 1 (plotly maps the post-‘normalized’ data linearly onto the interval [0,1] before mapping to a color), and R,`G`,and B are red, green, and blue floating point values in [0,1]. The color will be interpolated between the different “point” elements in this list.
- hminfloat
The minimum post-normalized values to be used for the heatmap. That is, hmin is the value (after normalize has been called) assigned the “0.0”-valued color in rgb_colors.
- hmaxfloat
The maximum post-normalized values to be used for the heatmap. That is, hmax is the value (after normalize has been called) assigned the “1.0”-valued color in rgb_colors.
- invalid_colortuple, optional
If not None, an (R,G,B) tuple of values in [0,1] specifying the color to use for normalized values (which usually should be in [0,1]) that lie outside the [0,1] range of rgb_colors.
Create a new Colormap.
Parameters
- rgb_colorslist
A list of [val, (R,G,B)] elements where val is a floating point number between 0 and 1 (plotly maps the post-‘normalized’ data linearly onto the interval [0,1] before mapping to a color), and R,`G`,and B are red, green, and blue floating point values in [0,1]. The color will be interpolated between the different “point” elements in this list.
- hmin, hmaxfloat
The minimum and maximum post-normalized values to be used for the heatmap. That is, hmin is the value (after normalize has been called) assigned the “0.0”-valued color in rgb_colors and hmax similarly for the “1.0”-valued color.
- invalid_colortuple, optional
If not None, an (R,G,B) tuple of values in [0,1] specifying the color to use for normalized values (which usually should be in [0,1]) that lie outside the [0,1] range of rgb_colors.
- rgb_colors
- invalid_color
- hmin
- hmax
- normalize(value)
Normalize value as it would be prior to linearly interpolating onto the [0,1] range of the color map.
In this case, no additional normalization is performed, so this function just returns value.
Parameters
- valuefloat or numpy.ndarray
The value to normalize.
Returns
float or numpy.ndarray
- besttxtcolor(value)
Return the better text color, “black” or “white”, given an un-normalized value.
Parameters
- valuefloat
An un-normalized value.
Returns
str
- create_plotly_colorscale()
Construct and return the plotly colorscale of this color map.
Returns
- list
A list of [float_value, “rgb(R,G,B)”] items.
- interpolate_color(value)
Retrieves the color at a particular colormap value.
This function linearly interpolates between the colors of a this colormap’s color scale
Parameters
- valuefloat
The value (before normalization) to compute the color for.
Returns
- str
A string representation of the plotly color of the form “rgb(R,G,B)”.
- class pygsti.report.colormaps.LinlogColormap(vmin, vmax, num_boxes, pcntle, dof_per_box, color='red')
Bases:
Colormap
Colormap which combines a linear grayscale portion with a logarithmic color (by default red) portion.
The transition between these occurs at a point based on a percentile of chi^2 distribution.
Parameters
- vminfloat
The minium value of the data being colormapped.
- vmaxfloat
The maximum value of the data being colormapped.
- num_boxesint
The number of boxes in the plot this colormap is being used with, so that pcntle gives a percentage of the worst box being “red”.
- pcntlefloat
A number between 0 and 1 giving the probability that the worst box in the plot will be red. Typically a value of 0.05 is used.
- dof_per_boxint
The number of degrees of freedom represented by each box, so the expected distribution of each box’s values is chi^2_[dof_per_box].
- color{“red”,”blue”,”green”,”cyan”,”yellow”,”purple”}
The color to use for the non-grayscale part of the color scale.
Create a new LinlogColormap.
Parameters
- vmin, vmaxfloat
The min and max values of the data being colormapped.
- num_boxesint
The number of boxes in the plot this colormap is being used with, so that pcntle gives a percentage of the worst box being “red”.
- pcntlefloat
A number between 0 and 1 giving the probability that the worst box in the plot will be red. Typically a value of 0.05 is used.
- dof_per_boxint
The number of degrees of freedom represented by each box, so the expected distribution of each box’s values is chi^2_[dof_per_box].
- color{“red”,”blue”,”green”,”cyan”,”yellow”,”purple”}
The color to use for the non-grayscale part of the color scale.
- N
- percentile
- dof
- trans
- vmin
- vmax
- classmethod set_manual_transition_point(vmin, vmax, trans, color='red')
Create a new LinlogColormap with a manually-specified transition point.
Parameters
- vminfloat
The minium value of the data being colormapped.
- vmaxfloat
The maximum value of the data being colormapped.
- transfloat
The transition-point value between the linear grayscale and logarithmic colorscale.
- color{“red”,”blue”,”green”,”cyan”,”yellow”,”purple”}
the color to use for the non-grayscale part of the color scale.
Returns
LinlogColormap
- class pygsti.report.colormaps.DivergingColormap(vmin, vmax, midpoint=0.0, color='RdBu')
Bases:
Colormap
A diverging color map
Parameters
- vminfloat
The minium value of the data being colormapped.
- vmaxfloat
The maximum value of the data being colormapped.
- midpointfloat, optional
The midpoint of the color scale.
- color{“RdBu”}
What colors to use.
Create a new DivergingColormap
Parameters
- vmin, vmaxfloat
Min and max values of the data being colormapped.
- midpointfloat, optional
The midpoint of the color scale.
- color{“RdBu”}
What colors to use.
- midpoint
- class pygsti.report.colormaps.SequentialColormap(vmin, vmax, color='whiteToBlack')
Bases:
Colormap
A sequential color map
Parameters
- vminfloat
The minium value of the data being colormapped.
- vmaxfloat
The maximum value of the data being colormapped.
- color{“whiteToBlack”, “blackToWhite”}
What colors to use.
Create a new SequentialColormap
Parameters
- vmin, vmaxfloat
Min and max values of the data being colormapped.
- color{“whiteToBlack”, “blackToWhite”}
What colors to use.
- class pygsti.report.colormaps.PiecewiseLinearColormap(rgb_colors)
Bases:
Colormap
A piecewise-linear color map
Parameters
- rgb_colorslist
A list of [val, (R,G,B)] elements where val is a floating point number (pre-normalization) of the value corresponding to the color given by R,`G`,and B: red, green, and blue floating point values in [0,1]. The color will be interpolated between the different “point” elements in this list.
Create a new PiecewiseLinearColormap
Parameters
- rgb_colorslist
A list of [val, (R,G,B)] elements where val is a floating point number (pre-normalization) of the value corresponding to the color given by R,`G`,and B: red, green, and blue floating point values in [0,1]. The color will be interpolated between the different “point” elements in this list.