deepcave.utils.styled_plotty¶
# Styled Plotty
This module provides utilities for styling and customizing different plots with plotly. For this, it uses plotly as well as dash.
Functions
|
Generate HTML components to display code. |
|
Get an RGBA Color, currently (Plotly version 5.3.1) there are 10 possible colors. |
|
Generate a discrete colorscale from a (nested) list or numpy array of values. |
|
Generate hover text with metrics for a configuration. |
|
Generate tick data for both tickvals and ticktext. |
|
Generate tick data for both values and labels. |
|
Convert a hex_string to a tuple of rgb values. |
|
Take a label and prettifies it. |
|
Save a plotly figure as an image. |
- deepcave.utils.styled_plotty.generate_config_code(register, variables)[source]¶
Generate HTML components to display code.
- Parameters:
register (Callable) – A Callable for registering Dash components. The register_input function is located in the Plugin class.
variables (List[str]) – A List of variable names.
- Returns:
A List of Dash components.
- Return type:
List[Component]
- deepcave.utils.styled_plotty.get_color(id_, alpha=1)[source]¶
Get an RGBA Color, currently (Plotly version 5.3.1) there are 10 possible colors.
- Parameters:
id (int) – ID for retrieving a specific color.
alpha (float, optional) – Alpha value for the color, by default 1.
- Returns:
The color from the color palette.
- Return type:
Union[str, Tuple[float, float, float, float]]
- deepcave.utils.styled_plotty.get_discrete_heatmap(x, y, values, labels)[source]¶
Generate a discrete colorscale from a (nested) list or numpy array of values.
- Parameters:
x (List[Union[float, int]]) – List of values that present the x-axis of the heatmap.
y (List[int]) – List of values that present the y-axis of the heatmap.
values (List[Any]) – Contains the data values for the heatmap.
labels (List[Any]) – Contains the labels corresponding to the values.
- Returns:
A Plotly Heatmap object corresponding to the input.
- Return type:
go.Heatmap
- deepcave.utils.styled_plotty.get_hovertext_from_config(run, config_id, budget=None)[source]¶
Generate hover text with metrics for a configuration.
The method gets information about a given configuration, including a link, its objectives, budget, costs and hyperparameters.
- Parameters:
run (AbstractRun) – The run instance
config_id (int) – The id of the configuration
budget (Optional[Union[int, float]]) – Budget to get the hovertext for. If no budget is given, the highest budget is chosen. By default None.
- Returns:
The hover text string containing the configuration information.
- Return type:
str
- deepcave.utils.styled_plotty.get_hyperparameter_ticks(hp, additional_values=None, ticks=4, include_nan=True)[source]¶
Generate tick data for both tickvals and ticktext.
The background is that you might have encoded data, but you don’t want to show all of them. With this function, only 6 (default) values are shown. This behavior is ignored if hp is categorical.
- Parameters:
hp (Hyperparameter) – Hyperparameter to generate ticks from.
additional_values (Optional[List], optional) – Additional values, which are forced in addition. By default, None.
ticks (int, optional) – Number of ticks, by default 4
include_nan (bool, optional) – Whether “nan” as tick should be included. By default True.
- Returns:
tickvals and ticktext.
- Return type:
Tuple[List, List]
- deepcave.utils.styled_plotty.get_hyperparameter_ticks_from_values(values, labels, forced=None, ticks=6)[source]¶
Generate tick data for both values and labels.
The background is that you might have encoded data, but you don’t want to show all of them. With this function, only 6 (default) values are shown. This behavior is ignored if values is a list of strings.
- Parameters:
values (List) – List of values.
labels (List) – List of labels. Must be the same size as values.
forced (Optional[List[bool]], optional) – List of booleans. If True, displaying the particular tick is enforced. Independent of ticks.
ticks (int, optional) – Number of ticks and labels to show. By default 6.
- Returns:
Returns tickvals and ticktext as list.
- Return type:
Tuple[List, List]
- Raises:
RuntimeError – If values contain both strings and non-strings.
- deepcave.utils.styled_plotty.hex_to_rgb(hex_string)[source]¶
Convert a hex_string to a tuple of rgb values.
Requires format including #, e.g.: #000000 #ff00ff
- Parameters:
hex_string (str) – The hex string to be converted.
- Returns:
A Tuple of the converted RGB values
- Return type:
Tuple[int, int, int]
- Raises:
ValueError – If the hex string is longer than 7. If there are invalid characters in the hex string.