py_research.colors module
Simple & semi-automatic color-system for data visualization purposes.
-
default_highlights()[source]
Return default highlight colors.
-
default_scales()[source]
Return default color scale.
-
class ColorTheme(highlights=<factory>, scales=<factory>)[source]
Bases: object
Define a color theme. Can be used as context manager to activate the theme.
- Parameters:
-
-
highlights: dict[Any, str]
Highlight colors for different, known categories.
-
scales: dict[Any, list[tuple[float, str]]]
Named or numbered color sclales.
-
activate()[source]
Set this as the current theme.
-
get_theme()[source]
Return active color theme (may be derived from current execution context).
- Return type:
ColorTheme
-
to_bg_color(color, lightness=0.8)[source]
Turn a highlight color into a background color.
- Parameters:
-
- Return type:
str
-
default_file_path = PosixPath('/home/runner/work/py-research/py-research/colors.yaml')
Default path to color theme file.
-
load_from_file(path=None)[source]
Load color theme from file.
- Parameters:
path (Path | str | None) – Path to file. If None, the default file path is used.
- Returns:
Path to the loaded file, if not given as argument.
- Return type:
Path | None