statworx_theme 0.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 An Hoang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.1
2
+ Name: statworx_theme
3
+ Version: 0.13.0
4
+ Summary: A color theme for matplotlib using the offical statworx design
5
+ Home-page: https://statworx-theme.readthedocs.io/en/latest
6
+ License: MIT
7
+ Keywords: theme,matplotlib,plotting,statworx
8
+ Author: statworx Team
9
+ Author-email: accounts@statworx.com
10
+ Requires-Python: >=3.8,<3.12
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Provides-Extra: altair
18
+ Provides-Extra: plotly
19
+ Requires-Dist: altair (>=5.2.0) ; extra == "altair"
20
+ Requires-Dist: nbformat (>=5.4.0) ; extra == "plotly"
21
+ Requires-Dist: plotly (>=5.10.0) ; extra == "plotly"
22
+ Requires-Dist: seaborn (>=0.11.2)
23
+ Requires-Dist: statsmodels (>=0.13.0) ; extra == "plotly"
24
+ Requires-Dist: vega-datasets (>=0.9.0) ; extra == "altair"
25
+ Project-URL: Repository, https://github.com/STATWORX/statworx-theme
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Statworx Theme
29
+
30
+ [![PyPI version](https://badge.fury.io/py/statworx-theme.svg)](https://badge.fury.io/py/statworx-theme)
31
+ [![Documentation Status](https://readthedocs.org/projects/statworx-theme/badge/?version=latest)](https://statworx-theme.readthedocs.io/en/latest/?badge=latest)
32
+ [![Release](https://github.com/STATWORX/statworx-theme/actions/workflows/release.yml/badge.svg)](https://github.com/STATWORX/statworx-theme/actions/workflows/release.yml)
33
+ [![Code Quality](https://github.com/STATWORX/statworx-theme/actions/workflows/conde_quality.yml/badge.svg)](https://github.com/STATWORX/statworx-theme/actions/workflows/conde_quality.yml)
34
+ [![Python version](https://img.shields.io/badge/python-3.8-blue.svg)](https://pypi.org/project/kedro/)
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/STATWORX/statworx-theme/blob/master/LICENSE)
36
+ ![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
37
+
38
+ A color theme plugin for the [matplotlib](https://matplotlib.org/) library and all its derivatives, as well as an optional adaption of this theme for [altair](https://altair-viz.github.io/) and [plotly](https://plotly.com/python/), which automatically applies the official statworx color theme.
39
+ This package also registers commonly used [qualitative color maps](https://matplotlib.org/stable/tutorials/colors/colormaps.html) (such as a fade from good to bad) for use in presentations.
40
+
41
+ ![Sample](./docs/assets/sample.svg)
42
+
43
+ ## Quick Start
44
+
45
+ Simply install a module with `pip` by using the following command.
46
+
47
+ ```console
48
+ pip install statworx-theme
49
+ ```
50
+
51
+ For usage of altair and plotly extra dependencies need to be installed using pip.
52
+
53
+ ```console
54
+ pip install "statworx-theme[altair]"
55
+ pip install "statworx-theme[plotly]"
56
+ ```
57
+
58
+ For using the styles inside a poetry managed project use `poetry add` with extras.
59
+ ```console
60
+ #only matplotlib
61
+ poetry add statworx-theme
62
+
63
+ # altair theme
64
+ poetry add statworx-theme -E "altair"
65
+
66
+ # plotly theme
67
+ poetry add statworx-theme -E "plotly"
68
+
69
+ # Whole package
70
+ poetry add statworx-theme -E "altair plotly"
71
+ ```
72
+
73
+
74
+ To apply the matplotlib style, you must call the `apply_style` function by typing:
75
+
76
+ ```python
77
+ from statworx_theme import apply_style
78
+ apply_style()
79
+ ```
80
+
81
+ For applying the plotly or altair style the respective `apply_style_<library>` function is used:
82
+ ```python
83
+ from statworx_theme import apply_style_altair, apply_style_plotly
84
+ apply_style_altair()
85
+ apply_style_plotly()
86
+ ```
87
+
88
+
89
+ ## Gallery
90
+
91
+ #### Matplotlib
92
+ There is an extensive gallery of figures that use the Statworx theme that you can draw inspiration from. You can find it [here](https://statworx-theme.readthedocs.io/en/latest/gallery.html).
93
+ For a figure gallery using the altair and plotly theme see the respective notebooks inside the [repository](https://github.com/STATWORX/statworx-theme/tree/master/notebooks).
94
+
95
+ ![Sample](./docs/assets/gallery.png)
96
+
97
+ ## Custom Colors
98
+
99
+ You can also use a custom list of color for the color scheme beside the official statworx colors.
100
+ There is a convenience function for that which is described below.
101
+ This simply changes the colors.
102
+
103
+ ##### Matplotlib
104
+ In case you want to change the entire style you should implement your own `.mplstyle` file (see [this](https://matplotlib.org/stable/tutorials/introductory/customizing.html)).
105
+
106
+ ```python
107
+ from statworx_theme import apply_custom_colors
108
+
109
+ custom_colors = [
110
+ DARK_BLUE := "#0A526B",
111
+ DARK_RED := "#6B0020",
112
+ GREY := "#808285",
113
+ ]
114
+ apply_custom_colors(custom_colors)
115
+ ```
116
+
117
+ #### Altair
118
+
119
+ ```python
120
+ from statworx_theme import apply_custom_colors_altair
121
+
122
+ custom_colors = [
123
+ DARK_BLUE := "#0A526B",
124
+ DARK_RED := "#6B0020",
125
+ GREY := "#808285",
126
+ ]
127
+ apply_custom_colors_altair(category=custom_colors)
128
+ ```
129
+
130
+ #### Plotly
131
+
132
+ ```python
133
+ from statworx_theme import apply_custom_colors_plotly
134
+ custom_colors = [
135
+ DARK_BLUE := "#0A526B",
136
+ DARK_RED := "#6B0020",
137
+ GREY := "#808285",
138
+ ]
139
+ apply_custom_colors_plotly(category=custom_colors)
140
+ ```
141
+
@@ -0,0 +1,113 @@
1
+ # Statworx Theme
2
+
3
+ [![PyPI version](https://badge.fury.io/py/statworx-theme.svg)](https://badge.fury.io/py/statworx-theme)
4
+ [![Documentation Status](https://readthedocs.org/projects/statworx-theme/badge/?version=latest)](https://statworx-theme.readthedocs.io/en/latest/?badge=latest)
5
+ [![Release](https://github.com/STATWORX/statworx-theme/actions/workflows/release.yml/badge.svg)](https://github.com/STATWORX/statworx-theme/actions/workflows/release.yml)
6
+ [![Code Quality](https://github.com/STATWORX/statworx-theme/actions/workflows/conde_quality.yml/badge.svg)](https://github.com/STATWORX/statworx-theme/actions/workflows/conde_quality.yml)
7
+ [![Python version](https://img.shields.io/badge/python-3.8-blue.svg)](https://pypi.org/project/kedro/)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/STATWORX/statworx-theme/blob/master/LICENSE)
9
+ ![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
10
+
11
+ A color theme plugin for the [matplotlib](https://matplotlib.org/) library and all its derivatives, as well as an optional adaption of this theme for [altair](https://altair-viz.github.io/) and [plotly](https://plotly.com/python/), which automatically applies the official statworx color theme.
12
+ This package also registers commonly used [qualitative color maps](https://matplotlib.org/stable/tutorials/colors/colormaps.html) (such as a fade from good to bad) for use in presentations.
13
+
14
+ ![Sample](./docs/assets/sample.svg)
15
+
16
+ ## Quick Start
17
+
18
+ Simply install a module with `pip` by using the following command.
19
+
20
+ ```console
21
+ pip install statworx-theme
22
+ ```
23
+
24
+ For usage of altair and plotly extra dependencies need to be installed using pip.
25
+
26
+ ```console
27
+ pip install "statworx-theme[altair]"
28
+ pip install "statworx-theme[plotly]"
29
+ ```
30
+
31
+ For using the styles inside a poetry managed project use `poetry add` with extras.
32
+ ```console
33
+ #only matplotlib
34
+ poetry add statworx-theme
35
+
36
+ # altair theme
37
+ poetry add statworx-theme -E "altair"
38
+
39
+ # plotly theme
40
+ poetry add statworx-theme -E "plotly"
41
+
42
+ # Whole package
43
+ poetry add statworx-theme -E "altair plotly"
44
+ ```
45
+
46
+
47
+ To apply the matplotlib style, you must call the `apply_style` function by typing:
48
+
49
+ ```python
50
+ from statworx_theme import apply_style
51
+ apply_style()
52
+ ```
53
+
54
+ For applying the plotly or altair style the respective `apply_style_<library>` function is used:
55
+ ```python
56
+ from statworx_theme import apply_style_altair, apply_style_plotly
57
+ apply_style_altair()
58
+ apply_style_plotly()
59
+ ```
60
+
61
+
62
+ ## Gallery
63
+
64
+ #### Matplotlib
65
+ There is an extensive gallery of figures that use the Statworx theme that you can draw inspiration from. You can find it [here](https://statworx-theme.readthedocs.io/en/latest/gallery.html).
66
+ For a figure gallery using the altair and plotly theme see the respective notebooks inside the [repository](https://github.com/STATWORX/statworx-theme/tree/master/notebooks).
67
+
68
+ ![Sample](./docs/assets/gallery.png)
69
+
70
+ ## Custom Colors
71
+
72
+ You can also use a custom list of color for the color scheme beside the official statworx colors.
73
+ There is a convenience function for that which is described below.
74
+ This simply changes the colors.
75
+
76
+ ##### Matplotlib
77
+ In case you want to change the entire style you should implement your own `.mplstyle` file (see [this](https://matplotlib.org/stable/tutorials/introductory/customizing.html)).
78
+
79
+ ```python
80
+ from statworx_theme import apply_custom_colors
81
+
82
+ custom_colors = [
83
+ DARK_BLUE := "#0A526B",
84
+ DARK_RED := "#6B0020",
85
+ GREY := "#808285",
86
+ ]
87
+ apply_custom_colors(custom_colors)
88
+ ```
89
+
90
+ #### Altair
91
+
92
+ ```python
93
+ from statworx_theme import apply_custom_colors_altair
94
+
95
+ custom_colors = [
96
+ DARK_BLUE := "#0A526B",
97
+ DARK_RED := "#6B0020",
98
+ GREY := "#808285",
99
+ ]
100
+ apply_custom_colors_altair(category=custom_colors)
101
+ ```
102
+
103
+ #### Plotly
104
+
105
+ ```python
106
+ from statworx_theme import apply_custom_colors_plotly
107
+ custom_colors = [
108
+ DARK_BLUE := "#0A526B",
109
+ DARK_RED := "#6B0020",
110
+ GREY := "#808285",
111
+ ]
112
+ apply_custom_colors_plotly(category=custom_colors)
113
+ ```
@@ -0,0 +1,45 @@
1
+ [tool.poetry]
2
+ name = "statworx_theme"
3
+ version = "0.13.0"
4
+ description = "A color theme for matplotlib using the offical statworx design"
5
+ authors = [
6
+ "statworx Team <accounts@statworx.com>",
7
+ "An Hoang <an.hoang@statworx.com>",
8
+ "Benedikt Batton <benedikt.batton@statworx.com>",
9
+ ]
10
+ readme = "README.md"
11
+ license = "MIT"
12
+ keywords = ["theme", "matplotlib", "plotting", "statworx"]
13
+ repository = "https://github.com/STATWORX/statworx-theme"
14
+ homepage = "https://statworx-theme.readthedocs.io/en/latest"
15
+
16
+ [tool.poetry.dependencies]
17
+ python = ">=3.8,<3.12"
18
+ seaborn = ">=0.11.2"
19
+ altair = { version = ">=5.2.0", optional = true }
20
+ plotly = { version = ">=5.10.0", optional = true }
21
+ nbformat = { version = ">=5.4.0", optional = true }
22
+ vega-datasets = { version = ">=0.9.0", optional = true }
23
+ statsmodels = { version = ">=0.13.0", optional = true }
24
+
25
+ [tool.poetry.dev-dependencies]
26
+ black = ">=22.3.0"
27
+ commitizen = ">=2.21.2"
28
+ darglint = ">=1.8.1"
29
+ flake8 = ">=4.0.1"
30
+ ipykernel = ">=6.9.2"
31
+ mkdocs = ">=1.3.0"
32
+ mkdocs-material = ">=8.2.8"
33
+ mkdocstrings = ">=0.18.1"
34
+ mkdocstrings-python = ">=0.6.6"
35
+ mkdocs-matplotlib = ">=0.8.3"
36
+ pre-commit = ">=2.18.0"
37
+ mkdocs-include-markdown-plugin = "^3.3.0"
38
+
39
+ [tool.poetry.extras]
40
+ altair = ["altair", "vega-datasets"]
41
+ plotly = ["plotly", "nbformat", "statsmodels"]
42
+
43
+ [build-system]
44
+ requires = ["poetry-core>=1.0.0"]
45
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,16 @@
1
+ """statworx_theme module."""
2
+
3
+ from .colormaps import *
4
+ from .utils import ( # unimport:skip
5
+ apply_custom_colors,
6
+ apply_custom_colors_altair,
7
+ apply_custom_colors_plotly,
8
+ apply_style,
9
+ apply_style_altair,
10
+ apply_style_plotly,
11
+ get_stwx_cmaps,
12
+ register_blended_cmap,
13
+ register_listed_cmap,
14
+ )
15
+
16
+ __version__ = "0.13.0"
@@ -0,0 +1,94 @@
1
+ """Colormaps for the statworx theme."""
2
+ from itertools import product
3
+
4
+ from .colors import (
5
+ BLACK,
6
+ BLUE,
7
+ COLOR_DICT,
8
+ DARK_GREEN,
9
+ DARK_RED,
10
+ DEEP_BLUE,
11
+ DEEP_CYAN,
12
+ DEEP_GREEN,
13
+ DEEP_GREY,
14
+ DEEP_ORANGE,
15
+ DEEP_RED,
16
+ DEEP_VIOLET,
17
+ DEEP_YELLOW,
18
+ LIGHT_BLUE,
19
+ LIGHT_GREEN,
20
+ LIGHT_GREY,
21
+ LIGHT_RED,
22
+ WHITE,
23
+ )
24
+ from .utils import register_blended_cmap, register_listed_cmap
25
+
26
+ ####################################################################################################
27
+ # DISCRETE COLORMAPS
28
+ ####################################################################################################
29
+
30
+ standard_colors = [
31
+ BLUE,
32
+ LIGHT_GREY,
33
+ LIGHT_BLUE,
34
+ DEEP_GREY,
35
+ DARK_RED,
36
+ LIGHT_GREEN,
37
+ LIGHT_RED,
38
+ DARK_GREEN,
39
+ ]
40
+ standard_cmap = register_listed_cmap(standard_colors, "stwx:standard")
41
+
42
+ alternative_colors = [
43
+ BLUE,
44
+ LIGHT_GREY,
45
+ DARK_RED,
46
+ LIGHT_GREEN,
47
+ LIGHT_BLUE,
48
+ DEEP_GREY,
49
+ LIGHT_RED,
50
+ DARK_GREEN,
51
+ ]
52
+ alternative_cmap = register_listed_cmap(alternative_colors, "stwx:alternative")
53
+
54
+
55
+ deep_colors = [
56
+ DEEP_BLUE,
57
+ DEEP_RED,
58
+ DEEP_GREEN,
59
+ DEEP_VIOLET,
60
+ DEEP_CYAN,
61
+ DEEP_ORANGE,
62
+ ]
63
+ deep_cmap = register_listed_cmap(deep_colors, "stwx:deep")
64
+
65
+ ####################################################################################################
66
+ # BLENDED COLORMAPS
67
+ ####################################################################################################
68
+
69
+ bad2good_colors = [DARK_RED, DEEP_YELLOW, DARK_GREEN]
70
+ bad2good_cmap = register_blended_cmap(bad2good_colors, "stwx:bad2good")
71
+
72
+ good2bad_colors = [DARK_GREEN, DEEP_YELLOW, DARK_RED]
73
+ good2bad_cmap = register_blended_cmap(good2bad_colors, "stwx:good2bad")
74
+
75
+ for (name1, color1), (name2, color2) in product(COLOR_DICT.items(), COLOR_DICT.items()):
76
+ cmap_colors_ = [color1, WHITE, color2]
77
+ cmap_name_ = f"stwx:{name1}{name2}_diverging"
78
+ register_blended_cmap(cmap_colors_, cmap_name_)
79
+
80
+ for (name1, color1), (name2, color2) in product(COLOR_DICT.items(), COLOR_DICT.items()):
81
+ if name1 != name2:
82
+ cmap_colors_ = [color1, color2]
83
+ cmap_name_ = f"stwx:{name1}{name2}_blend"
84
+ register_blended_cmap(cmap_colors_, cmap_name_)
85
+
86
+ for name, color in COLOR_DICT.items():
87
+ cmap_colors_ = [color, WHITE]
88
+ cmap_name_ = f"stwx:{name}_fade"
89
+ register_blended_cmap(cmap_colors_, cmap_name_)
90
+
91
+ for name, color in COLOR_DICT.items():
92
+ cmap_colors_ = [BLACK, color, WHITE]
93
+ cmap_name_ = f"stwx:{name}_rise"
94
+ register_blended_cmap(cmap_colors_, cmap_name_)
@@ -0,0 +1,59 @@
1
+ """Color definitions for the statworx theme."""
2
+ from typing import Dict
3
+
4
+ # black and white
5
+ BLACK = "#000000"
6
+ WHITE = "#FFFFFF"
7
+
8
+ # GREY
9
+ DEEP_GREY = "#6C7D8C"
10
+ DARK_GREY = "#7D8AA4"
11
+ DARKER_GREY = "#283440"
12
+ GRAY = "#B6BDCC"
13
+ LIGHT_GREY = "#9BAEC1"
14
+ LIGHTER_GREY = "#EBF0F2"
15
+
16
+ # YELLOW
17
+ DEEP_YELLOW = "#FFFF00"
18
+
19
+ # VIOLEt
20
+ DEEP_VIOLET = "#7f00ff"
21
+
22
+ # CYAN
23
+ DEEP_CYAN = "#01BAEF"
24
+
25
+ # ORANGE
26
+ DEEP_ORANGE = "#FF781F"
27
+
28
+ # BLUE
29
+ DEEP_BLUE = "#0000FF"
30
+ BLUE = "#0000BF"
31
+ LIGHT_BLUE = "#9999FF"
32
+
33
+ # RED
34
+ DARK_RED = "#C7014F"
35
+ DEEP_RED = "#FE0D6C"
36
+ LIGHT_RED = "#FF9EC4"
37
+
38
+ # GREEN
39
+ DEEP_GREEN = "#00C800"
40
+ LIGHT_GREEN = "#83FF83"
41
+ DARK_GREEN = "#009600"
42
+
43
+ # define standard colors
44
+ C0 = BLUE
45
+ C1 = LIGHT_GREY
46
+ C2 = LIGHT_BLUE
47
+ C3 = DEEP_GREY
48
+ C4 = DARK_RED
49
+ C5 = LIGHT_GREEN
50
+ C6 = LIGHT_RED
51
+ C7 = DARK_GREEN
52
+
53
+ # create color dict
54
+ COLOR_DICT: Dict[str, str] = {
55
+ "Rd": DARK_RED,
56
+ "Bl": BLUE,
57
+ "Gn": DARK_GREEN,
58
+ "Yw": DEEP_YELLOW,
59
+ }