colors
Utilities for manipulating colors.
BNF
<sequence-color-spec> ::= { "A": <color-spec>, "C": <color-spec>, "G": <color-spec>, "T": <color-spec> }
<color-spec> ::= {"rgb": [<number>, <number>, <number>]} | {"rgba": [<number>, <number>, <number>, <number>]} | {"tol": <integer>} | {"tol-light": <integer>} | {"ibm": <integer>} | {"wong": <integer>} | [<number>, <number>, <number>«, <number>»]
<list-of-sequence-color-spec> ::= <sequence-color-spec>«, <list-of-sequence-color-spec>»
<list-of-color-spec> ::= <color-spec>«, <list-of-color-spec>»
- bpreveal.colors.tol: tuple[tuple[float, float, float] | tuple[float, float, float, float], ...]
The muted color scheme by Paul Tol.
- Type:
tuple[
RGB_T, …]
- bpreveal.colors.ibm: tuple[tuple[float, float, float] | tuple[float, float, float, float], ...]
The IBM design library’s color blind palette.
- Type:
tuple[
RGB_T, …]
- bpreveal.colors.wong: tuple[tuple[float, float, float] | tuple[float, float, float, float], ...]
Bang Wong’s palette. Used for DNA.
- Type:
tuple[
RGB_T, …]
- bpreveal.colors.tolLight: tuple[tuple[float, float, float] | tuple[float, float, float, float], ...]
The light color scheme by Paul Tol, but with light blue and olive deleted.
- Type:
tuple[
RGB_T, …]
- bpreveal.colors.dnaWong: DNA_COLOR_SPEC_T = {'A': {'wong': 3}, 'C': {'wong': 5}, 'G': {'wong': 4}, 'T': {'wong': 6}}
The default color map for DNA bases.
A is green, C is blue, G is yellow, and T is red.
- bpreveal.colors.defaultProfile: dict[Literal['rgb'], tuple[float, float, float]] | dict[Literal['rgba'], tuple[float, float, float, float]] | dict[Literal['tol'], int] | dict[Literal['tol-light'], int] | dict[Literal['ibm'], int] | dict[Literal['wong'], int] | tuple[float, float, float] | tuple[float, float, float, float]
The default color for profile plots. It’s tol[0].
- Type:
- bpreveal.colors.pisaClip = <matplotlib.colors.ListedColormap object>
The color map used for PISA plots, including green and pink clipping colors.
- bpreveal.colors.pisaNoClip = <matplotlib.colors.ListedColormap object>
The color map for PISA plots but without the clipping warning colors.
- bpreveal.colors.getGraphCmap(minValue, colorSpan, baseCmap)
Remove the central portion of a color map for PISA graphs.
- Parameters:
minValue (float) – The value (in logit space) below which no lines will be drawn in the PISA graph. This is the region of the returned color map that will be white.
colorSpan (float) – The total range of the color map. Lines with higher PISA scores than colorSpan will be clipped to the extreme values of the color map.
baseCmap (Colormap) – The colormap to modify. This will be either
pisaCliporpisaNoClip, or you may provide your own Colormap object.
- Returns:
A new color map that can be used to color lines in a PISA graph.
- Return type:
Colormap
- bpreveal.colors.parseSpec(colorSpec)
Given a color-spec (See the BNF), convert it into an rgb or rgba tuple.
- Parameters:
colorSpec (
COLOR_SPEC_T| str) – The color specification.- Returns:
An rgb triple (or rgba quadruple).
- Return type:
tuple[float, float, float] | tuple[float, float, float, float]
Based on the shape of colorSpec, this function interprets it differently. If colorSpec is a…
- 3-tuple
it is interpreted as an rgb color,
- 4-tuple
it is interpreted as rgba,
{"rgb": (0.1, 0.2, 0.3)}it is interpreted as an rgb color,
{"rgba": (0.1, 0.2, 0.3, 0.8)}it is interpreted as an rgba color,
{"<palette-name>": 3}where
<palette-name>is one of “tol”, “tol-light”, “wong”, or “ibm”), then the value is the coloriin the corresponding palette."b"or any other string, then it is interpreted as a matplotlib color string and is passed to
matplotlib.colors.to_rgb.
- bpreveal.colors.loadFonts(serif=True)
Configure the matplotlib default fonts to be in the Libertinus family.
- Parameters:
serif (bool) – Should a serif font be used? The default is True, and this will use the Libertinus font family. If False, then instead the Fira Sans font family will be used.
- Return type:
None
This places the given font (Libertinus or Fira Sans) at the top of the order for serif and sans-serif fontfamily, but does not overwrite the monospace family. It also sets the pdf backend to save text boxes rather than individual letters so that text can be easily edited later.