Skip to content

Commit a81bafc

Browse files
committed
add violin-plot
1 parent bffd54b commit a81bafc

6 files changed

Lines changed: 1050 additions & 0 deletions

File tree

examples/violin-plot.ipynb

Lines changed: 120 additions & 0 deletions
Large diffs are not rendered by default.

examples/violin-plot.png

98.5 KB
Loading

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ build-backend = "uv_build"
1616
[dependency-groups]
1717
dev = [
1818
"black>=24.8.0",
19+
"ipykernel>=6.29.5",
1920
"matplotlib>=3.7.5",
2021
"numpy>=1.24.4",
22+
"pip>=25.0.1",
2123
"pre-commit>=3.5.0",
2224
"pytest>=8.3.5",
2325
"ruff>=0.14.0",

src/physics_plot/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .utils import Handles
2+
3+
__all__ = [Handles]

src/physics_plot/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Handles(list):
2+
def __init__(self, *args):
3+
super().__init__(*args)
4+
5+
def append_violinplot(self, violinplot, label):
6+
self.append(self._create_patch_from_violinplot(violinplot, label))
7+
8+
def _create_patch_from_violinplot(self, violinplot, label):
9+
from matplotlib.patches import Patch
10+
11+
body = violinplot["bodies"][0]
12+
color = body.get_facecolor()[0]
13+
return Patch(color=color, label=label)

0 commit comments

Comments
 (0)