Code Documentation
statworx_theme.utils
_create_altair_theme(primary, category, diverging, heatmap, ramp, ordinal, name)
Creates the altair theme and registeres it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary |
str
|
The primary color as hexadecimal string (e.g. "#d9d9d9"). |
required |
category |
List[str]
|
Categorical colors as list of hexadecimal strings. |
required |
diverging |
List[str]
|
Diverging color palette as list of hexadecimal strings. |
required |
heatmap |
List[str]
|
Heatmap color palette as list of hexadecimal strings. |
required |
ramp |
List[str]
|
Ramp color palette as list of hexadecimal strings. |
required |
ordinal |
List[str]
|
Ordinal color plaette as list of hexadecimal strings. |
required |
name |
str
|
The name of the theme. |
required |
Source code in statworx_theme/utils.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
_create_plotly_theme(category, diverging, sequential, sequential_minus, heatmap, name)
Creates the plotly theme and registeres it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category |
List[str]
|
Categorical colors as list of hexadecimal strings. |
required |
diverging |
List[str]
|
Diverging color palette as list of hexadecimal strings. |
required |
sequential |
List[str]
|
Sequential color palette as list of hexadecimal strings. |
required |
sequential_minus |
List[str]
|
Downwards sequential color palette as list of hexadecimal strings. |
required |
heatmap |
List[str]
|
Heatmap color plaette as list of hexadecimal strings. |
required |
name |
str
|
The name of the theme. |
required |
Source code in statworx_theme/utils.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
_install_styles()
Install matplotlib style files with suffix .mplstyle to the matplotlib config dir.
Source code in statworx_theme/utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
_shrink_cmap(cmap, n_groups)
Shrinks the cmap for a fixed number of groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmap |
List[str]
|
The colormap. |
required |
n_groups |
int
|
The number of groups in the data to plot. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Shrunken cmap. |
Source code in statworx_theme/utils.py
152 153 154 155 156 157 158 159 160 161 162 163 | |
apply_custom_colors(colors, cmap_name='stwx:custom', **kwargs)
Apply custom custom colors to statworx style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors |
List[str]
|
List of custom colors as hex codes |
required |
cmap_name |
str
|
Custom name of new colormap. Defaults to "stwx:custom". |
'stwx:custom'
|
**kwargs |
Any
|
Addition parameters that are passed to the style config |
{}
|
Source code in statworx_theme/utils.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
apply_custom_colors_altair(primary=None, category=None, diverging=None, heatmap=None, ramp=None, ordinal=None, n_groups_ordinal=10)
Applies a custom altair theme with custom color palettes to the statworx style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary |
str
|
The primary color as hexadecimal string (e.g. "#d9d9d9"). Defaults to None (statworx style is kept). |
None
|
category |
List[str]
|
Categorical colors as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
diverging |
List[str]
|
Diverging color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
heatmap |
List[str]
|
Heatmap color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
ramp |
List[str]
|
Ramp color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
ordinal |
List[str]
|
Ordinal color plaette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
n_groups_ordinal |
int
|
The number of groups to be plotted using the ordinal color map. Defaults to 10. |
10
|
Source code in statworx_theme/utils.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
apply_custom_colors_plotly(category=None, diverging=None, sequential=None, sequential_minus=None, heatmap=None)
Applies a custom plotly theme with custom color palettes to the statworx style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category |
List[str]
|
Categorical colors as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
diverging |
List[str]
|
Diverging color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
sequential |
List[str]
|
Sequential color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
sequential_minus |
List[str]
|
Downwards sequential color palette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
heatmap |
List[str]
|
Heatmap color plaette as list of hexadecimal strings. Defaults to None (statworx style is kept). |
None
|
Source code in statworx_theme/utils.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
apply_style()
Apply the statworx color style.
Source code in statworx_theme/utils.py
76 77 78 79 | |
apply_style_altair(n_groups_ordinal=10)
Apply the statworx color style for Altair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_groups_ordinal |
int
|
The number of groups to be plotted for the ordinal color map. Defaults to 10. |
10
|
Source code in statworx_theme/utils.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
apply_style_plotly()
Apply the statworx color style for plotly.
Source code in statworx_theme/utils.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
get_stwx_cmaps(as_hex=True)
Gets the registered colormaps as hex or cmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
as_hex |
bool
|
Should the cmaps be returned as hexadecimal list or as a cmap. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary with the colormap name as a key and the hex-list or cmap as value. |
Source code in statworx_theme/utils.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
register_blended_cmap(colors, name)
Register a blended colormap to matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors |
List[str]
|
Colors of the colormap |
required |
name |
str
|
Name of the colormap |
required |
Returns:
| Type | Description |
|---|---|
LinearSegmentedColormap
|
Registered Colormap |
Source code in statworx_theme/utils.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
register_listed_cmap(colors, name)
Register a listed colormat in matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors |
List[str]
|
Color of the colormap |
required |
name |
str
|
Name of the colormap |
required |
Returns:
| Type | Description |
|---|---|
ListedColormap
|
Registered Colormap |
Source code in statworx_theme/utils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |