bumplot 0.2.1__tar.gz → 0.3.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.
- bumplot-0.3.0/.github/workflows/doc.yaml +32 -0
- bumplot-0.3.0/.github/workflows/lint.yaml +30 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/.github/workflows/pypi.yaml +1 -1
- {bumplot-0.2.1 → bumplot-0.3.0}/.github/workflows/tests.yaml +2 -2
- {bumplot-0.2.1 → bumplot-0.3.0}/.github/workflows/type.yaml +11 -5
- {bumplot-0.2.1 → bumplot-0.3.0}/.gitignore +2 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/PKG-INFO +13 -19
- bumplot-0.2.1/docs/index.md → bumplot-0.3.0/README.md +12 -8
- bumplot-0.3.0/bumplot/__init__.py +5 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot/_utils.py +4 -1
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot/bezier.py +13 -7
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot/main.py +20 -27
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot/opts.py +10 -11
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot.egg-info/PKG-INFO +13 -19
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot.egg-info/SOURCES.txt +2 -4
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/advanced-usage.md +21 -5
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/examples.md +56 -20
- bumplot-0.2.1/docs/README.qmd → bumplot-0.3.0/docs/index.md +14 -29
- bumplot-0.3.0/justfile +16 -0
- bumplot-0.3.0/pyproject.toml +57 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/tests/test_main.py +7 -8
- {bumplot-0.2.1 → bumplot-0.3.0}/tests/test_opts.py +14 -14
- bumplot-0.3.0/zensical.toml +58 -0
- bumplot-0.2.1/.github/workflows/doc.yaml +0 -41
- bumplot-0.2.1/.github/workflows/lint.yaml +0 -28
- bumplot-0.2.1/README.md +0 -70
- bumplot-0.2.1/bumplot/__init__.py +0 -5
- bumplot-0.2.1/justfile +0 -15
- bumplot-0.2.1/mkdocs.yaml +0 -61
- bumplot-0.2.1/overrides/partials/footer.html +0 -7
- bumplot-0.2.1/pyproject.toml +0 -63
- {bumplot-0.2.1 → bumplot-0.3.0}/.coverage +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/.pre-commit-config.yaml +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/LICENSE +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot.egg-info/dependency_links.txt +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot.egg-info/requires.txt +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/bumplot.egg-info/top_level.txt +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/coverage-badge.svg +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/.gitignore +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/contributing.md +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/data/water-africa.csv +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/reference/bezier.md +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/reference/bumplot.md +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/docs/stylesheets/style.css +0 -0
- /bumplot-0.2.1/README_files/figure-commonmark/cell-3-output-1.png → /bumplot-0.3.0/example.png +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/setup.cfg +0 -0
- {bumplot-0.2.1 → bumplot-0.3.0}/tests/__init__.py +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v6
|
|
13
|
+
- uses: actions/setup-python@v6
|
|
14
|
+
with:
|
|
15
|
+
python-version: 3.x
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
|
|
22
|
+
- name: Install the project
|
|
23
|
+
run: uv sync --all-groups
|
|
24
|
+
|
|
25
|
+
- run: uv run zensical build --clean
|
|
26
|
+
|
|
27
|
+
- name: Deploy to GitHub Pages
|
|
28
|
+
uses: peaceiris/actions-gh-pages@v4
|
|
29
|
+
with:
|
|
30
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
publish_branch: gh-pages
|
|
32
|
+
publish_dir: ./site
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Check code formatting
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check-formatting:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout repository
|
|
15
|
+
uses: actions/checkout@v6
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Install the project
|
|
25
|
+
run: uv sync --all-groups
|
|
26
|
+
|
|
27
|
+
- name: Run Ruff formatter and linter
|
|
28
|
+
run: |
|
|
29
|
+
uv run ruff format --check .
|
|
30
|
+
uv run ruff check
|
|
@@ -11,11 +11,11 @@ jobs:
|
|
|
11
11
|
matrix:
|
|
12
12
|
python-version:
|
|
13
13
|
- "3.10"
|
|
14
|
-
- "3.
|
|
14
|
+
- "3.15"
|
|
15
15
|
env:
|
|
16
16
|
UV_PYTHON: ${{ matrix.python-version }}
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
19
|
|
|
20
20
|
- name: Install uv
|
|
21
21
|
uses: astral-sh/setup-uv@v5
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
name: Check
|
|
1
|
+
name: Check static typing
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
4
6
|
pull_request:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
+
branches: [main]
|
|
7
8
|
|
|
8
9
|
jobs:
|
|
9
10
|
check-formatting:
|
|
@@ -11,7 +12,9 @@ jobs:
|
|
|
11
12
|
|
|
12
13
|
steps:
|
|
13
14
|
- name: Checkout repository
|
|
14
|
-
uses: actions/checkout@
|
|
15
|
+
uses: actions/checkout@v6
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
15
18
|
|
|
16
19
|
- name: Install uv
|
|
17
20
|
uses: astral-sh/setup-uv@v5
|
|
@@ -21,5 +24,8 @@ jobs:
|
|
|
21
24
|
- name: Install the project
|
|
22
25
|
run: uv sync --all-groups
|
|
23
26
|
|
|
24
|
-
- name:
|
|
27
|
+
- name: ty
|
|
25
28
|
run: uv run ty check
|
|
29
|
+
|
|
30
|
+
- name: pyrefly
|
|
31
|
+
run: uv run pyrefly check
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bumplot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Easily create and customize bump charts in Python
|
|
5
5
|
Author-email: Joseph Barbier <joseph.barbierdarnal@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
|
+
Project-URL: Documentation, https://y-sunflower.github.io/bumplot/
|
|
7
8
|
Project-URL: Homepage, https://y-sunflower.github.io/bumplot/
|
|
8
9
|
Project-URL: Issues, https://github.com/y-sunflower/bumplot/issues
|
|
9
|
-
Project-URL: Documentation, https://y-sunflower.github.io/bumplot/
|
|
10
10
|
Project-URL: Repository, https://github.com/y-sunflower/bumplot
|
|
11
|
-
Keywords: bump,bump
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
+
Keywords: bezier,bump,bump charts,bump plot,curve,data,matplotlib,visualization
|
|
14
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
@@ -21,20 +21,13 @@ Dynamic: license-file
|
|
|
21
21
|
|
|
22
22
|
# `bumplot`: easily create and customize bump charts in Python
|
|
23
23
|
|
|
24
|
-
<!-- Automatically generated, uses README.qmd to modify README.md -->
|
|
25
|
-
|
|
26
24
|
<img src="https://github.com/JosephBARBIERDARNAL/static/blob/main/python-libs/bumplot/image.png?raw=true" alt="bumplot logo" align="right" width="180px"/>
|
|
27
25
|
|
|
28
|
-
`bumplot` is a small Python package made to facilitate the creation of
|
|
29
|
-
**bump charts** using matplotlib and Bézier curves. It has high
|
|
30
|
-
customization capabilities too!
|
|
26
|
+
`bumplot` is a small Python package made to facilitate the creation of **bump charts** using matplotlib and Bézier curves. It has high customization capabilities too!
|
|
31
27
|
|
|
32
|
-
Bump charts are useful when the focus is on comparing **relative
|
|
33
|
-
rankings**—who is ahead of whom—rather than the exact magnitude of the
|
|
34
|
-
differences.
|
|
28
|
+
Bump charts are useful when the focus is on comparing **relative rankings**—who is ahead of whom—rather than the exact magnitude of the differences.
|
|
35
29
|
|
|
36
|
-
Check out the [online
|
|
37
|
-
documentation](https://y-sunflower.github.io/bumplot/)
|
|
30
|
+
Check out the [online documentation](https://y-sunflower.github.io/bumplot/)
|
|
38
31
|
|
|
39
32
|
<br> <br>
|
|
40
33
|
|
|
@@ -70,7 +63,7 @@ ax.spines[["top", "right", "left", "bottom"]].set_visible(False)
|
|
|
70
63
|
ax.grid(alpha=0.4)
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-

|
|
74
67
|
|
|
75
68
|
[See more examples](https://y-sunflower.github.io/bumplot/examples/)
|
|
76
69
|
|
|
@@ -78,14 +71,15 @@ ax.grid(alpha=0.4)
|
|
|
78
71
|
|
|
79
72
|
## Installation
|
|
80
73
|
|
|
81
|
-
|
|
74
|
+
```sh
|
|
75
|
+
pip install bumplot
|
|
76
|
+
```
|
|
82
77
|
|
|
83
78
|
<br><br>
|
|
84
79
|
|
|
85
80
|
## Features
|
|
86
81
|
|
|
87
|
-
- Automatic ranking of your data (with support for both `pandas` and
|
|
88
|
-
`polars`)
|
|
82
|
+
- Automatic ranking of your data (with support for both `pandas` and `polars`)
|
|
89
83
|
- Accept categorical data for x-axis
|
|
90
84
|
- Infinite customization capabilities
|
|
91
85
|
- Easy control of the curvature intensity
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
Bump charts are useful when the focus is on comparing **relative rankings**—who is ahead of whom—rather than the exact magnitude of the differences.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<br>
|
|
9
|
+
Check out the [online documentation](https://y-sunflower.github.io/bumplot/)
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
<br> <br>
|
|
12
|
+
|
|
13
|
+
## Get started
|
|
13
14
|
|
|
14
15
|
```python
|
|
15
|
-
# mkdocs: render
|
|
16
16
|
import matplotlib.pyplot as plt
|
|
17
17
|
import pandas as pd
|
|
18
18
|
|
|
@@ -42,19 +42,23 @@ ax.spines[["top", "right", "left", "bottom"]].set_visible(False)
|
|
|
42
42
|
ax.grid(alpha=0.4)
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
[
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
[See more examples](https://y-sunflower.github.io/bumplot/examples/)
|
|
48
|
+
|
|
49
|
+
<br> <br>
|
|
46
50
|
|
|
47
51
|
## Installation
|
|
48
52
|
|
|
49
|
-
```
|
|
53
|
+
```sh
|
|
50
54
|
pip install bumplot
|
|
51
55
|
```
|
|
52
56
|
|
|
57
|
+
<br><br>
|
|
58
|
+
|
|
53
59
|
## Features
|
|
54
60
|
|
|
55
61
|
- Automatic ranking of your data (with support for both `pandas` and `polars`)
|
|
56
62
|
- Accept categorical data for x-axis
|
|
57
63
|
- Infinite customization capabilities
|
|
58
64
|
- Easy control of the curvature intensity
|
|
59
|
-
|
|
60
|
-
<br>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
1
3
|
import narwhals as nw
|
|
4
|
+
from narwhals import DataFrame
|
|
2
5
|
from narwhals.typing import IntoDataFrame
|
|
3
6
|
|
|
4
7
|
|
|
5
|
-
def _ranked_df(df: IntoDataFrame, x: str, y_columns: list[str]):
|
|
8
|
+
def _ranked_df(df: IntoDataFrame, x: str, y_columns: list[str]) -> DataFrame[Any]:
|
|
6
9
|
"""
|
|
7
10
|
Convert a dataframe to a ranked version of it.
|
|
8
11
|
"""
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from matplotlib.path import Path
|
|
2
1
|
import numpy as np
|
|
2
|
+
from matplotlib.path import Path
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def bezier_curve(
|
|
@@ -25,18 +25,24 @@ def bezier_curve(
|
|
|
25
25
|
vertices: List of (x, y) vertices including control points for the Bézier segments.
|
|
26
26
|
codes: Corresponding matplotlib Path codes for constructing the curve.
|
|
27
27
|
"""
|
|
28
|
-
vertices
|
|
29
|
-
codes
|
|
28
|
+
vertices = []
|
|
29
|
+
codes = []
|
|
30
30
|
|
|
31
|
-
vertices.append((x[0], y[0]))
|
|
32
|
-
codes.append(Path.MOVETO)
|
|
31
|
+
vertices.append((float(x[0]), float(y[0])))
|
|
32
|
+
codes.append(int(Path.MOVETO))
|
|
33
33
|
|
|
34
34
|
for i in range(1, len(x)):
|
|
35
35
|
x0, y0 = x[i - 1], y[i - 1]
|
|
36
36
|
x1, y1 = x[i], y[i]
|
|
37
37
|
dx = (x1 - x0) * force
|
|
38
38
|
|
|
39
|
-
vertices.extend(
|
|
40
|
-
|
|
39
|
+
vertices.extend(
|
|
40
|
+
[
|
|
41
|
+
(float(x0 + dx), float(y0)),
|
|
42
|
+
(float(x1 - dx), float(y1)),
|
|
43
|
+
(float(x1), float(y1)),
|
|
44
|
+
]
|
|
45
|
+
)
|
|
46
|
+
codes.extend([int(Path.CURVE4)] * 3)
|
|
41
47
|
|
|
42
48
|
return vertices, codes
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
from collections import
|
|
1
|
+
from collections.abc import Iterable
|
|
2
2
|
from itertools import cycle
|
|
3
|
+
from typing import Any
|
|
3
4
|
|
|
4
5
|
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
from matplotlib import patches
|
|
5
8
|
from matplotlib.axes import Axes
|
|
6
|
-
from matplotlib.path import Path
|
|
7
|
-
import matplotlib.patches as patches
|
|
8
9
|
from matplotlib.cbook import normalize_kwargs
|
|
9
10
|
from matplotlib.collections import PathCollection
|
|
10
11
|
from matplotlib.patches import PathPatch
|
|
11
|
-
|
|
12
|
-
import numpy as np
|
|
13
|
-
|
|
12
|
+
from matplotlib.path import Path
|
|
14
13
|
from narwhals.typing import IntoDataFrame
|
|
15
14
|
|
|
16
|
-
from .bezier import bezier_curve
|
|
17
15
|
from ._utils import _ranked_df, _to_ordinal
|
|
16
|
+
from .bezier import bezier_curve
|
|
18
17
|
from .opts import BumpOpts, _get_plot_kwargs, _get_scatter_kwargs
|
|
19
18
|
|
|
20
|
-
from typing import Any, Iterable, Tuple
|
|
21
|
-
|
|
22
19
|
|
|
23
20
|
def bumplot(
|
|
24
21
|
x: str,
|
|
@@ -27,11 +24,11 @@ def bumplot(
|
|
|
27
24
|
curve_force: float = 1,
|
|
28
25
|
invert_y_axis: bool = True,
|
|
29
26
|
colors: Iterable[str] | None = None,
|
|
30
|
-
plot_kwargs: dict[str, Any] =
|
|
31
|
-
scatter_kwargs: dict[str, Any] =
|
|
27
|
+
plot_kwargs: dict[str, Any] | None = None,
|
|
28
|
+
scatter_kwargs: dict[str, Any] | None = None,
|
|
32
29
|
ax: Axes | None = None,
|
|
33
30
|
ordinal_labels: bool = False,
|
|
34
|
-
) ->
|
|
31
|
+
) -> tuple[Axes, dict[str, tuple[PathPatch, PathCollection]]]:
|
|
35
32
|
"""
|
|
36
33
|
Creates bump plot, or bump chart, from multiple numerical
|
|
37
34
|
columns.
|
|
@@ -55,6 +52,8 @@ def bumplot(
|
|
|
55
52
|
Returns:
|
|
56
53
|
The matplotlib Axes with the bump plot
|
|
57
54
|
"""
|
|
55
|
+
plot_kwargs = {} if plot_kwargs is None else plot_kwargs
|
|
56
|
+
scatter_kwargs = {} if scatter_kwargs is None else scatter_kwargs
|
|
58
57
|
_plot_ax: Axes = ax if ax is not None else plt.gca()
|
|
59
58
|
colors_iterable = (
|
|
60
59
|
colors
|
|
@@ -65,7 +64,7 @@ def bumplot(
|
|
|
65
64
|
y_bumps: list[tuple[str, BumpOpts]] = [
|
|
66
65
|
(y, BumpOpts()) if isinstance(y, str) else y for y in y_columns
|
|
67
66
|
]
|
|
68
|
-
ranked
|
|
67
|
+
ranked = _ranked_df(data, x=x, y_columns=[y for y, _ in y_bumps])
|
|
69
68
|
x_values_raw: np.ndarray = np.ravel(ranked.select(x).to_numpy())
|
|
70
69
|
|
|
71
70
|
if np.issubdtype(x_values_raw.dtype, np.number):
|
|
@@ -87,26 +86,20 @@ def bumplot(
|
|
|
87
86
|
)
|
|
88
87
|
|
|
89
88
|
path: Path = Path(vertices=vertices, codes=codes)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
_get_plot_kwargs(bump_opts),
|
|
95
|
-
normalize_kwargs(plot_kwargs, PathPatch),
|
|
96
|
-
{"edgecolor": color},
|
|
97
|
-
),
|
|
98
|
-
)
|
|
89
|
+
path_kwargs: dict[str, Any] = {"edgecolor": color}
|
|
90
|
+
path_kwargs.update(normalize_kwargs(plot_kwargs, PathPatch))
|
|
91
|
+
path_kwargs.update(_get_plot_kwargs(bump_opts))
|
|
92
|
+
patch: PathPatch = patches.PathPatch(path=path, facecolor="none", **path_kwargs)
|
|
99
93
|
_plot_ax.add_patch(patch)
|
|
100
94
|
|
|
95
|
+
artist_scatter_kwargs: dict[str, Any] = {"facecolor": color}
|
|
96
|
+
artist_scatter_kwargs.update(normalize_kwargs(scatter_kwargs, PathCollection))
|
|
97
|
+
artist_scatter_kwargs.update(_get_scatter_kwargs(bump_opts))
|
|
101
98
|
scatter = _plot_ax.scatter(
|
|
102
99
|
x_values,
|
|
103
100
|
y_values,
|
|
104
101
|
label=name,
|
|
105
|
-
**
|
|
106
|
-
_get_scatter_kwargs(bump_opts),
|
|
107
|
-
normalize_kwargs(scatter_kwargs, PathCollection),
|
|
108
|
-
{"facecolor": color},
|
|
109
|
-
),
|
|
102
|
+
**artist_scatter_kwargs,
|
|
110
103
|
)
|
|
111
104
|
artists[name] = (patch, scatter)
|
|
112
105
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypedDict, cast
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class BumpOpts(TypedDict, total=False):
|
|
@@ -151,12 +152,11 @@ def _get_plot_kwargs(kwargs: BumpOpts, /) -> dict[str, Any]:
|
|
|
151
152
|
-----
|
|
152
153
|
- Only keys present in both `kwargs` and `PLOT_MAPPINGS` are included.
|
|
153
154
|
"""
|
|
154
|
-
|
|
155
|
+
kwargs_mapping = cast(Mapping[str, Any], kwargs)
|
|
156
|
+
plot_kwargs: dict[str, Any] = {}
|
|
155
157
|
for bump_arg, mpl_arg in PLOT_MAPPINGS.items():
|
|
156
|
-
|
|
157
|
-
plot_kwargs[mpl_arg] =
|
|
158
|
-
except KeyError:
|
|
159
|
-
pass
|
|
158
|
+
if bump_arg in kwargs_mapping:
|
|
159
|
+
plot_kwargs[mpl_arg] = kwargs_mapping[bump_arg]
|
|
160
160
|
return plot_kwargs
|
|
161
161
|
|
|
162
162
|
|
|
@@ -182,10 +182,9 @@ def _get_scatter_kwargs(kwargs: BumpOpts, /) -> dict[str, Any]:
|
|
|
182
182
|
-----
|
|
183
183
|
- Only keys present in both `kwargs` and `SCATTER_MAPPINGS` are included.
|
|
184
184
|
"""
|
|
185
|
-
|
|
185
|
+
kwargs_mapping = cast(Mapping[str, Any], kwargs)
|
|
186
|
+
scatter_kwargs: dict[str, Any] = {}
|
|
186
187
|
for bump_arg, mpl_arg in SCATTER_MAPPINGS.items():
|
|
187
|
-
|
|
188
|
-
scatter_kwargs[mpl_arg] =
|
|
189
|
-
except KeyError:
|
|
190
|
-
pass
|
|
188
|
+
if bump_arg in kwargs_mapping:
|
|
189
|
+
scatter_kwargs[mpl_arg] = kwargs_mapping[bump_arg]
|
|
191
190
|
return scatter_kwargs
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bumplot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Easily create and customize bump charts in Python
|
|
5
5
|
Author-email: Joseph Barbier <joseph.barbierdarnal@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
|
+
Project-URL: Documentation, https://y-sunflower.github.io/bumplot/
|
|
7
8
|
Project-URL: Homepage, https://y-sunflower.github.io/bumplot/
|
|
8
9
|
Project-URL: Issues, https://github.com/y-sunflower/bumplot/issues
|
|
9
|
-
Project-URL: Documentation, https://y-sunflower.github.io/bumplot/
|
|
10
10
|
Project-URL: Repository, https://github.com/y-sunflower/bumplot
|
|
11
|
-
Keywords: bump,bump
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
+
Keywords: bezier,bump,bump charts,bump plot,curve,data,matplotlib,visualization
|
|
14
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
@@ -21,20 +21,13 @@ Dynamic: license-file
|
|
|
21
21
|
|
|
22
22
|
# `bumplot`: easily create and customize bump charts in Python
|
|
23
23
|
|
|
24
|
-
<!-- Automatically generated, uses README.qmd to modify README.md -->
|
|
25
|
-
|
|
26
24
|
<img src="https://github.com/JosephBARBIERDARNAL/static/blob/main/python-libs/bumplot/image.png?raw=true" alt="bumplot logo" align="right" width="180px"/>
|
|
27
25
|
|
|
28
|
-
`bumplot` is a small Python package made to facilitate the creation of
|
|
29
|
-
**bump charts** using matplotlib and Bézier curves. It has high
|
|
30
|
-
customization capabilities too!
|
|
26
|
+
`bumplot` is a small Python package made to facilitate the creation of **bump charts** using matplotlib and Bézier curves. It has high customization capabilities too!
|
|
31
27
|
|
|
32
|
-
Bump charts are useful when the focus is on comparing **relative
|
|
33
|
-
rankings**—who is ahead of whom—rather than the exact magnitude of the
|
|
34
|
-
differences.
|
|
28
|
+
Bump charts are useful when the focus is on comparing **relative rankings**—who is ahead of whom—rather than the exact magnitude of the differences.
|
|
35
29
|
|
|
36
|
-
Check out the [online
|
|
37
|
-
documentation](https://y-sunflower.github.io/bumplot/)
|
|
30
|
+
Check out the [online documentation](https://y-sunflower.github.io/bumplot/)
|
|
38
31
|
|
|
39
32
|
<br> <br>
|
|
40
33
|
|
|
@@ -70,7 +63,7 @@ ax.spines[["top", "right", "left", "bottom"]].set_visible(False)
|
|
|
70
63
|
ax.grid(alpha=0.4)
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-

|
|
74
67
|
|
|
75
68
|
[See more examples](https://y-sunflower.github.io/bumplot/examples/)
|
|
76
69
|
|
|
@@ -78,14 +71,15 @@ ax.grid(alpha=0.4)
|
|
|
78
71
|
|
|
79
72
|
## Installation
|
|
80
73
|
|
|
81
|
-
|
|
74
|
+
```sh
|
|
75
|
+
pip install bumplot
|
|
76
|
+
```
|
|
82
77
|
|
|
83
78
|
<br><br>
|
|
84
79
|
|
|
85
80
|
## Features
|
|
86
81
|
|
|
87
|
-
- Automatic ranking of your data (with support for both `pandas` and
|
|
88
|
-
`polars`)
|
|
82
|
+
- Automatic ranking of your data (with support for both `pandas` and `polars`)
|
|
89
83
|
- Accept categorical data for x-axis
|
|
90
84
|
- Infinite customization capabilities
|
|
91
85
|
- Easy control of the curvature intensity
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
LICENSE
|
|
5
5
|
README.md
|
|
6
6
|
coverage-badge.svg
|
|
7
|
+
example.png
|
|
7
8
|
justfile
|
|
8
|
-
mkdocs.yaml
|
|
9
9
|
pyproject.toml
|
|
10
|
+
zensical.toml
|
|
10
11
|
.github/workflows/doc.yaml
|
|
11
12
|
.github/workflows/lint.yaml
|
|
12
13
|
.github/workflows/pypi.yaml
|
|
13
14
|
.github/workflows/tests.yaml
|
|
14
15
|
.github/workflows/type.yaml
|
|
15
|
-
README_files/figure-commonmark/cell-3-output-1.png
|
|
16
16
|
bumplot/__init__.py
|
|
17
17
|
bumplot/_utils.py
|
|
18
18
|
bumplot/bezier.py
|
|
@@ -24,7 +24,6 @@ bumplot.egg-info/dependency_links.txt
|
|
|
24
24
|
bumplot.egg-info/requires.txt
|
|
25
25
|
bumplot.egg-info/top_level.txt
|
|
26
26
|
docs/.gitignore
|
|
27
|
-
docs/README.qmd
|
|
28
27
|
docs/advanced-usage.md
|
|
29
28
|
docs/contributing.md
|
|
30
29
|
docs/examples.md
|
|
@@ -33,7 +32,6 @@ docs/data/water-africa.csv
|
|
|
33
32
|
docs/reference/bezier.md
|
|
34
33
|
docs/reference/bumplot.md
|
|
35
34
|
docs/stylesheets/style.css
|
|
36
|
-
overrides/partials/footer.html
|
|
37
35
|
tests/__init__.py
|
|
38
36
|
tests/test_main.py
|
|
39
37
|
tests/test_opts.py
|
|
@@ -9,9 +9,10 @@ These examples are also designed to be easy to reproduce: you should be able to
|
|
|
9
9
|
|
|
10
10
|
## Water sources in Africa
|
|
11
11
|
|
|
12
|
-
```
|
|
13
|
-
# mkdocs: render
|
|
12
|
+
```python exec="on" source="above" html="true"
|
|
14
13
|
import pandas as pd
|
|
14
|
+
import matplotlib # markdown-exec: hide
|
|
15
|
+
matplotlib.use("Agg") # markdown-exec: hide
|
|
15
16
|
import matplotlib.pyplot as plt
|
|
16
17
|
from pyfonts import set_default_font, load_google_font
|
|
17
18
|
|
|
@@ -36,7 +37,7 @@ _, bump_artists = bumplot(
|
|
|
36
37
|
data=df,
|
|
37
38
|
curve_force=0.7,
|
|
38
39
|
ordinal_labels=True,
|
|
39
|
-
colors=["lightgray"]
|
|
40
|
+
colors=["lightgray"],
|
|
40
41
|
)
|
|
41
42
|
ax.spines[["top", "right", "left", "bottom"]].set_visible(False)
|
|
42
43
|
ax.margins(x=0.01)
|
|
@@ -87,6 +88,13 @@ fig.text(
|
|
|
87
88
|
font=load_google_font("Poppins", italic=True),
|
|
88
89
|
size=10,
|
|
89
90
|
)
|
|
91
|
+
from base64 import b64encode # markdown-exec: hide
|
|
92
|
+
from io import BytesIO # markdown-exec: hide
|
|
93
|
+
|
|
94
|
+
buffer = BytesIO() # markdown-exec: hide
|
|
95
|
+
fig.savefig(buffer, format="png") # markdown-exec: hide
|
|
96
|
+
print('<img alt="Rendered plot" src="data:image/png;base64,{}">'.format(b64encode(buffer.getvalue()).decode())) # markdown-exec: hide
|
|
97
|
+
plt.close(fig) # markdown-exec: hide
|
|
90
98
|
```
|
|
91
99
|
|
|
92
100
|
<br>
|
|
@@ -94,9 +102,10 @@ fig.text(
|
|
|
94
102
|
|
|
95
103
|
## Global CO₂ Emissions Rankings
|
|
96
104
|
|
|
97
|
-
```
|
|
98
|
-
# mkdocs: render
|
|
105
|
+
```python exec="on" source="above" html="true"
|
|
99
106
|
import pandas as pd
|
|
107
|
+
import matplotlib # markdown-exec: hide
|
|
108
|
+
matplotlib.use("Agg") # markdown-exec: hide
|
|
100
109
|
import matplotlib.pyplot as plt
|
|
101
110
|
from pyfonts import set_default_font, load_google_font
|
|
102
111
|
|
|
@@ -228,4 +237,11 @@ fig.text(
|
|
|
228
237
|
font=font_bold,
|
|
229
238
|
size=8,
|
|
230
239
|
)
|
|
240
|
+
from base64 import b64encode # markdown-exec: hide
|
|
241
|
+
from io import BytesIO # markdown-exec: hide
|
|
242
|
+
|
|
243
|
+
buffer = BytesIO() # markdown-exec: hide
|
|
244
|
+
fig.savefig(buffer, format="png") # markdown-exec: hide
|
|
245
|
+
print('<img alt="Rendered plot" src="data:image/png;base64,{}">'.format(b64encode(buffer.getvalue()).decode())) # markdown-exec: hide
|
|
246
|
+
plt.close(fig) # markdown-exec: hide
|
|
231
247
|
```
|