plotify-charts 0.1.0__py3-none-any.whl
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.
- plotify/__init__.py +116 -0
- plotify/_inference.py +144 -0
- plotify/auto.py +360 -0
- plotify/base.py +224 -0
- plotify/categorical/__init__.py +37 -0
- plotify/categorical/bar_plot.py +121 -0
- plotify/categorical/circular_packing.py +107 -0
- plotify/categorical/dendrogram.py +113 -0
- plotify/categorical/doughnut_chart.py +109 -0
- plotify/categorical/lollipop_chart.py +168 -0
- plotify/categorical/parallel_coordinates.py +94 -0
- plotify/categorical/pie_chart.py +101 -0
- plotify/categorical/radar_chart.py +116 -0
- plotify/categorical/sunburst_diagram.py +117 -0
- plotify/categorical/treemap.py +121 -0
- plotify/categorical/venn_diagram.py +92 -0
- plotify/categorical/word_cloud.py +104 -0
- plotify/maps/__init__.py +21 -0
- plotify/maps/bubble_map.py +114 -0
- plotify/maps/cartogram.py +126 -0
- plotify/maps/choropleth_map.py +108 -0
- plotify/maps/connection_map.py +117 -0
- plotify/maps/hexbin_map.py +96 -0
- plotify/network/__init__.py +21 -0
- plotify/network/arc_diagram.py +124 -0
- plotify/network/chord_diagram.py +119 -0
- plotify/network/hierarchical_edge_bundling.py +141 -0
- plotify/network/network_diagram.py +167 -0
- plotify/network/sankey_diagram.py +258 -0
- plotify/num_cat/__init__.py +19 -0
- plotify/num_cat/box_plot_by_group.py +110 -0
- plotify/num_cat/grouped_bar_plot.py +110 -0
- plotify/num_cat/grouped_scatter.py +105 -0
- plotify/num_cat/stacked_bar_plot.py +117 -0
- plotify/numerical/__init__.py +21 -0
- plotify/numerical/boxplot.py +157 -0
- plotify/numerical/connected_scatter_plot.py +120 -0
- plotify/numerical/density_plot.py +184 -0
- plotify/numerical/scatter_plot.py +140 -0
- plotify/numerical/violin_plot.py +141 -0
- plotify/theme.py +297 -0
- plotify/timeseries/__init__.py +13 -0
- plotify/timeseries/area_chart.py +89 -0
- plotify/timeseries/line_chart.py +110 -0
- plotify/timeseries/stacked_area_chart.py +133 -0
- plotify/timeseries/stream_graph.py +116 -0
- plotify_charts-0.1.0.dist-info/LICENSE +21 -0
- plotify_charts-0.1.0.dist-info/METADATA +226 -0
- plotify_charts-0.1.0.dist-info/RECORD +50 -0
- plotify_charts-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
plotify.timeseries.line_chart
|
|
3
|
+
=============================
|
|
4
|
+
|
|
5
|
+
Dual-backend line chart — evolution of one or more numeric series over time.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import matplotlib.pyplot as plt
|
|
9
|
+
import plotly.express as px
|
|
10
|
+
import seaborn as sns
|
|
11
|
+
|
|
12
|
+
from plotify.base import BasePlot
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LineChart(BasePlot):
|
|
16
|
+
"""
|
|
17
|
+
Line chart.
|
|
18
|
+
|
|
19
|
+
Wraps :func:`seaborn.lineplot` (Seaborn backend) and
|
|
20
|
+
:func:`plotly.express.line` (Plotly backend).
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
df,
|
|
26
|
+
x,
|
|
27
|
+
y,
|
|
28
|
+
hue=None,
|
|
29
|
+
style=None,
|
|
30
|
+
markers=False,
|
|
31
|
+
dashes=True,
|
|
32
|
+
palette=None,
|
|
33
|
+
title=None,
|
|
34
|
+
backend="seaborn",
|
|
35
|
+
**kwargs,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
This is used to create a line chart.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
df : pandas.DataFrame
|
|
43
|
+
Input data.
|
|
44
|
+
x : str
|
|
45
|
+
Column for the x axis (typically a time column).
|
|
46
|
+
y : str
|
|
47
|
+
Column for the numeric y axis.
|
|
48
|
+
hue : str, optional
|
|
49
|
+
Column for colour grouping — one line per group.
|
|
50
|
+
style : str, optional
|
|
51
|
+
Column for line-style grouping (Seaborn only).
|
|
52
|
+
markers : bool, default=False
|
|
53
|
+
Whether to overlay point markers on each line.
|
|
54
|
+
dashes : bool, default=True
|
|
55
|
+
Whether to use dashed lines when ``style`` is set (Seaborn only).
|
|
56
|
+
palette : str or list, optional
|
|
57
|
+
Colour palette.
|
|
58
|
+
title : str, optional
|
|
59
|
+
Plot title.
|
|
60
|
+
backend : {"seaborn", "plotly"}, default="seaborn"
|
|
61
|
+
Rendering backend.
|
|
62
|
+
**kwargs :
|
|
63
|
+
Forwarded to the underlying library.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
None
|
|
68
|
+
"""
|
|
69
|
+
self.__df = df
|
|
70
|
+
self.__x = x
|
|
71
|
+
self.__y = y
|
|
72
|
+
self.__hue = hue
|
|
73
|
+
self.__style = style
|
|
74
|
+
self.__markers = markers
|
|
75
|
+
self.__dashes = dashes
|
|
76
|
+
self.__palette = palette
|
|
77
|
+
self.__kwargs = kwargs
|
|
78
|
+
|
|
79
|
+
super().__init__(backend=backend, title=title)
|
|
80
|
+
self._render()
|
|
81
|
+
|
|
82
|
+
def _plot_seaborn(self):
|
|
83
|
+
"""Render using :func:`seaborn.lineplot`."""
|
|
84
|
+
sns.lineplot(
|
|
85
|
+
data=self.__df,
|
|
86
|
+
x=self.__x,
|
|
87
|
+
y=self.__y,
|
|
88
|
+
hue=self.__hue,
|
|
89
|
+
style=self.__style,
|
|
90
|
+
markers=self.__markers,
|
|
91
|
+
dashes=self.__dashes,
|
|
92
|
+
palette=self.__palette,
|
|
93
|
+
**self.__kwargs,
|
|
94
|
+
)
|
|
95
|
+
if self._title:
|
|
96
|
+
plt.title(self._title)
|
|
97
|
+
|
|
98
|
+
def _plot_plotly(self):
|
|
99
|
+
"""Render using :func:`plotly.express.line`."""
|
|
100
|
+
fig = px.line(
|
|
101
|
+
self.__df,
|
|
102
|
+
x=self.__x,
|
|
103
|
+
y=self.__y,
|
|
104
|
+
color=self.__hue,
|
|
105
|
+
line_dash=self.__style,
|
|
106
|
+
markers=self.__markers,
|
|
107
|
+
title=self._title,
|
|
108
|
+
**self.__kwargs,
|
|
109
|
+
)
|
|
110
|
+
self._fig = fig
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""
|
|
2
|
+
plotify.timeseries.stacked_area_chart
|
|
3
|
+
=====================================
|
|
4
|
+
|
|
5
|
+
Dual-backend stacked area chart — multiple series stacked vertically.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import matplotlib.pyplot as plt
|
|
9
|
+
import plotly.express as px
|
|
10
|
+
|
|
11
|
+
from plotify.base import BasePlot
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class StackedAreaChart(BasePlot):
|
|
15
|
+
"""
|
|
16
|
+
Stacked area chart.
|
|
17
|
+
|
|
18
|
+
Accepts data in one of two shapes:
|
|
19
|
+
|
|
20
|
+
* **Wide** — pass ``y=[col1, col2, ...]`` so each named column becomes a
|
|
21
|
+
stacked layer.
|
|
22
|
+
* **Long** — pass ``y=<value_col>`` and ``hue=<group_col>``; the data is
|
|
23
|
+
reshaped internally.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
df,
|
|
29
|
+
x,
|
|
30
|
+
y,
|
|
31
|
+
hue=None,
|
|
32
|
+
colors=None,
|
|
33
|
+
alpha=0.7,
|
|
34
|
+
title=None,
|
|
35
|
+
backend="seaborn",
|
|
36
|
+
**kwargs,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
This is used to create a stacked area chart.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
df : pandas.DataFrame
|
|
44
|
+
Input data.
|
|
45
|
+
x : str
|
|
46
|
+
Column for the x axis.
|
|
47
|
+
y : str or list[str]
|
|
48
|
+
Either one value column (long form — requires ``hue``) or a list
|
|
49
|
+
of column names to stack directly (wide form).
|
|
50
|
+
hue : str, optional
|
|
51
|
+
Group column for long-form input.
|
|
52
|
+
colors : list[str], optional
|
|
53
|
+
Fill colours, one per layer (Seaborn only).
|
|
54
|
+
alpha : float, default=0.7
|
|
55
|
+
Fill transparency (Seaborn only).
|
|
56
|
+
title : str, optional
|
|
57
|
+
Plot title.
|
|
58
|
+
backend : {"seaborn", "plotly"}, default="seaborn"
|
|
59
|
+
Rendering backend.
|
|
60
|
+
**kwargs :
|
|
61
|
+
Forwarded to the underlying library.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
None
|
|
66
|
+
"""
|
|
67
|
+
if isinstance(y, str) and hue is None:
|
|
68
|
+
raise ValueError("When ``y`` is a single column, ``hue`` is required.")
|
|
69
|
+
|
|
70
|
+
self.__df = df
|
|
71
|
+
self.__x = x
|
|
72
|
+
self.__y = y
|
|
73
|
+
self.__hue = hue
|
|
74
|
+
self.__colors = colors
|
|
75
|
+
self.__alpha = alpha
|
|
76
|
+
self.__kwargs = kwargs
|
|
77
|
+
|
|
78
|
+
super().__init__(backend=backend, title=title)
|
|
79
|
+
self._render()
|
|
80
|
+
|
|
81
|
+
def _plot_seaborn(self):
|
|
82
|
+
"""Render using :func:`matplotlib.pyplot.stackplot`."""
|
|
83
|
+
if isinstance(self.__y, list):
|
|
84
|
+
# Wide form — stack each named column directly.
|
|
85
|
+
x_vals = self.__df[self.__x]
|
|
86
|
+
layers = [self.__df[c] for c in self.__y]
|
|
87
|
+
labels = self.__y
|
|
88
|
+
else:
|
|
89
|
+
# Long form — pivot to wide for stackplot.
|
|
90
|
+
wide = self.__df.pivot_table(
|
|
91
|
+
index=self.__x, columns=self.__hue, values=self.__y, aggfunc="sum"
|
|
92
|
+
).fillna(0)
|
|
93
|
+
x_vals = wide.index
|
|
94
|
+
layers = [wide[col] for col in wide.columns]
|
|
95
|
+
labels = list(wide.columns)
|
|
96
|
+
|
|
97
|
+
plt.stackplot(
|
|
98
|
+
x_vals,
|
|
99
|
+
*layers,
|
|
100
|
+
labels=labels,
|
|
101
|
+
colors=self.__colors,
|
|
102
|
+
alpha=self.__alpha,
|
|
103
|
+
)
|
|
104
|
+
plt.legend(loc="upper left")
|
|
105
|
+
if self._title:
|
|
106
|
+
plt.title(self._title)
|
|
107
|
+
|
|
108
|
+
def _plot_plotly(self):
|
|
109
|
+
"""Render using :func:`plotly.express.area` with stacking enabled."""
|
|
110
|
+
if isinstance(self.__y, list):
|
|
111
|
+
# Wide form — melt to long so px.area can stack.
|
|
112
|
+
long_df = self.__df.melt(
|
|
113
|
+
id_vars=[self.__x], value_vars=self.__y,
|
|
114
|
+
var_name="series", value_name="value",
|
|
115
|
+
)
|
|
116
|
+
fig = px.area(
|
|
117
|
+
long_df,
|
|
118
|
+
x=self.__x,
|
|
119
|
+
y="value",
|
|
120
|
+
color="series",
|
|
121
|
+
title=self._title,
|
|
122
|
+
**self.__kwargs,
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
fig = px.area(
|
|
126
|
+
self.__df,
|
|
127
|
+
x=self.__x,
|
|
128
|
+
y=self.__y,
|
|
129
|
+
color=self.__hue,
|
|
130
|
+
title=self._title,
|
|
131
|
+
**self.__kwargs,
|
|
132
|
+
)
|
|
133
|
+
self._fig = fig
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""
|
|
2
|
+
plotify.timeseries.stream_graph
|
|
3
|
+
===============================
|
|
4
|
+
|
|
5
|
+
Stream graph — a stacked area variant where layers flow around a central
|
|
6
|
+
baseline, producing the characteristic "ribbon" appearance.
|
|
7
|
+
|
|
8
|
+
Plotly has no native streamgraph primitive, so only the Seaborn/Matplotlib
|
|
9
|
+
backend is implemented.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import matplotlib.pyplot as plt
|
|
13
|
+
|
|
14
|
+
from plotify.base import BasePlot
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class StreamGraph(BasePlot):
|
|
18
|
+
"""
|
|
19
|
+
Stream graph.
|
|
20
|
+
|
|
21
|
+
Uses :func:`matplotlib.pyplot.stackplot` with ``baseline='wiggle'`` to
|
|
22
|
+
produce the signature symmetric flow.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
# Plotly has no native streamgraph.
|
|
26
|
+
SUPPORTED_BACKENDS = ("seaborn",)
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
df,
|
|
31
|
+
x,
|
|
32
|
+
y,
|
|
33
|
+
hue=None,
|
|
34
|
+
colors=None,
|
|
35
|
+
alpha=0.9,
|
|
36
|
+
baseline="wiggle",
|
|
37
|
+
title=None,
|
|
38
|
+
backend="seaborn",
|
|
39
|
+
**kwargs,
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
This is used to create a stream graph.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
df : pandas.DataFrame
|
|
47
|
+
Input data.
|
|
48
|
+
x : str
|
|
49
|
+
Column for the x axis (typically time).
|
|
50
|
+
y : str or list[str]
|
|
51
|
+
Either one value column (long form — requires ``hue``) or a list
|
|
52
|
+
of column names to stack directly (wide form).
|
|
53
|
+
hue : str, optional
|
|
54
|
+
Group column for long-form input.
|
|
55
|
+
colors : list[str], optional
|
|
56
|
+
Colour per layer.
|
|
57
|
+
alpha : float, default=0.9
|
|
58
|
+
Fill transparency.
|
|
59
|
+
baseline : {"wiggle", "sym", "zero", "weighted_wiggle"}, default="wiggle"
|
|
60
|
+
Stackplot baseline algorithm; ``"wiggle"`` gives the canonical
|
|
61
|
+
stream shape.
|
|
62
|
+
title : str, optional
|
|
63
|
+
Plot title.
|
|
64
|
+
backend : {"seaborn"}
|
|
65
|
+
Only the Seaborn/Matplotlib backend is supported.
|
|
66
|
+
**kwargs :
|
|
67
|
+
Forwarded to :func:`matplotlib.pyplot.stackplot`.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
None
|
|
72
|
+
"""
|
|
73
|
+
if isinstance(y, str) and hue is None:
|
|
74
|
+
raise ValueError("When ``y`` is a single column, ``hue`` is required.")
|
|
75
|
+
|
|
76
|
+
self.__df = df
|
|
77
|
+
self.__x = x
|
|
78
|
+
self.__y = y
|
|
79
|
+
self.__hue = hue
|
|
80
|
+
self.__colors = colors
|
|
81
|
+
self.__alpha = alpha
|
|
82
|
+
self.__baseline = baseline
|
|
83
|
+
self.__kwargs = kwargs
|
|
84
|
+
|
|
85
|
+
super().__init__(backend=backend, title=title)
|
|
86
|
+
self._render()
|
|
87
|
+
|
|
88
|
+
def _plot_seaborn(self):
|
|
89
|
+
"""Stack the series with a wiggled baseline."""
|
|
90
|
+
if isinstance(self.__y, list):
|
|
91
|
+
x_vals = self.__df[self.__x]
|
|
92
|
+
layers = [self.__df[c] for c in self.__y]
|
|
93
|
+
labels = self.__y
|
|
94
|
+
else:
|
|
95
|
+
wide = self.__df.pivot_table(
|
|
96
|
+
index=self.__x, columns=self.__hue, values=self.__y, aggfunc="sum"
|
|
97
|
+
).fillna(0)
|
|
98
|
+
x_vals = wide.index
|
|
99
|
+
layers = [wide[col] for col in wide.columns]
|
|
100
|
+
labels = list(wide.columns)
|
|
101
|
+
|
|
102
|
+
plt.stackplot(
|
|
103
|
+
x_vals,
|
|
104
|
+
*layers,
|
|
105
|
+
labels=labels,
|
|
106
|
+
colors=self.__colors,
|
|
107
|
+
alpha=self.__alpha,
|
|
108
|
+
baseline=self.__baseline,
|
|
109
|
+
**self.__kwargs,
|
|
110
|
+
)
|
|
111
|
+
# Stream graphs do not usually show a y-axis — the relative widths
|
|
112
|
+
# carry the information, absolute values do not.
|
|
113
|
+
plt.gca().set_yticks([])
|
|
114
|
+
plt.legend(loc="upper left")
|
|
115
|
+
if self._title:
|
|
116
|
+
plt.title(self._title)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kazi1318914 <mahin.kkgb.km@gmail.com>
|
|
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,226 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: plotify-charts
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python plotting package with a dual Seaborn/Matplotlib + Plotly backend.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: plotting,visualization,dataviz,matplotlib,plotly,seaborn,charts
|
|
7
|
+
Author: Kazi1318914
|
|
8
|
+
Author-email: mahin.kkgb.km@gmail.com
|
|
9
|
+
Requires-Python: >=3.10,<3.13
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
+
Provides-Extra: full
|
|
22
|
+
Provides-Extra: maps
|
|
23
|
+
Requires-Dist: circlify (>=0.15)
|
|
24
|
+
Requires-Dist: geopandas (>=0.14) ; extra == "maps" or extra == "full"
|
|
25
|
+
Requires-Dist: kaleido (==0.2.1)
|
|
26
|
+
Requires-Dist: matplotlib (>=3.7)
|
|
27
|
+
Requires-Dist: matplotlib-venn (>=0.11)
|
|
28
|
+
Requires-Dist: networkx (>=3.1)
|
|
29
|
+
Requires-Dist: numpy (>=1.24)
|
|
30
|
+
Requires-Dist: pandas (>=2.0)
|
|
31
|
+
Requires-Dist: plotly (>=5.18)
|
|
32
|
+
Requires-Dist: scipy (>=1.10)
|
|
33
|
+
Requires-Dist: seaborn (>=0.13)
|
|
34
|
+
Requires-Dist: squarify (>=0.4.3)
|
|
35
|
+
Requires-Dist: statsmodels (>=0.14)
|
|
36
|
+
Requires-Dist: wordcloud (>=1.9)
|
|
37
|
+
Project-URL: Homepage, https://github.com/Kazi1318914/Plotify
|
|
38
|
+
Project-URL: Repository, https://github.com/Kazi1318914/Plotify
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# Plotify
|
|
42
|
+
|
|
43
|
+
Plotify is a Python plotting package built around two ideas:
|
|
44
|
+
|
|
45
|
+
1. **Auto-pick** — given a dataframe and column names, Plotify infers the
|
|
46
|
+
right chart from the data shape and types. No need to remember which
|
|
47
|
+
function to call.
|
|
48
|
+
2. **Publication-ready by default** — every chart ships with a
|
|
49
|
+
colourblind-safe palette, smart tick formatting (1.2K, 3.4M),
|
|
50
|
+
minimalist spines, and consistent typography on both backends.
|
|
51
|
+
|
|
52
|
+
Every plot can render on either Seaborn/Matplotlib (static images) or
|
|
53
|
+
Plotly (interactive HTML).
|
|
54
|
+
|
|
55
|
+
The chart catalogue and category split (Numerical, Categoric, Num & Cat,
|
|
56
|
+
Time series, Network, Maps) are inspired by
|
|
57
|
+
[data-to-viz.com](https://www.data-to-viz.com/).
|
|
58
|
+
|
|
59
|
+
## Demo notebooks
|
|
60
|
+
|
|
61
|
+
The fastest way to see what Plotify can do — runnable notebooks under
|
|
62
|
+
[`notebooks/`](notebooks/) with every chart class rendered on both backends:
|
|
63
|
+
|
|
64
|
+
- [`00_quickstart.ipynb`](notebooks/00_quickstart.ipynb) — `auto`, `suggest`, themes
|
|
65
|
+
- [`01_numerical.ipynb`](notebooks/01_numerical.ipynb) — Boxplot, Density, Violin, Scatter, ConnectedScatter
|
|
66
|
+
- [`02_categorical.ipynb`](notebooks/02_categorical.ipynb) — all 12 categoric charts
|
|
67
|
+
- [`03_num_cat.ipynb`](notebooks/03_num_cat.ipynb) — GroupedBar, StackedBar, GroupedScatter, BoxPlotByGroup
|
|
68
|
+
- [`04_timeseries.ipynb`](notebooks/04_timeseries.ipynb) — Line, Area, StackedArea, StreamGraph
|
|
69
|
+
- [`05_network.ipynb`](notebooks/05_network.ipynb) — Network, Chord, Sankey, Arc, HierarchicalEdgeBundling
|
|
70
|
+
- [`06_maps.ipynb`](notebooks/06_maps.ipynb) — Choropleth, Bubble, Hexbin, Cartogram, Connection
|
|
71
|
+
|
|
72
|
+
Outputs are committed, so the notebooks render fully on GitHub without
|
|
73
|
+
running them.
|
|
74
|
+
|
|
75
|
+
## Two-line example
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import pandas as pd, plotify
|
|
79
|
+
|
|
80
|
+
df = pd.DataFrame({
|
|
81
|
+
"date": pd.date_range("2024-01-01", periods=12, freq="MS"),
|
|
82
|
+
"sales": [120, 140, 90, 200, 220, 260, 240, 310, 280, 330, 360, 410],
|
|
83
|
+
"region": ["North"] * 6 + ["South"] * 6,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
plotify.auto(df, x="date", y="sales", color="region", backend="plotly")\
|
|
87
|
+
.save_plot("sales.html")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`plotify.auto` looks at the dtypes (datetime, numeric, low-cardinality
|
|
91
|
+
group), picks `LineChart`, and returns a beautifully themed figure.
|
|
92
|
+
|
|
93
|
+
## What `auto` actually picks
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
plotify.suggest(df, x="date", y="sales", color="region")
|
|
97
|
+
# → [Suggestion(LineChart, score=0.96, reason="datetime x + numeric y + low-cardinality group → multi-series line chart"),
|
|
98
|
+
# Suggestion(StackedAreaChart, score=0.72, reason="stacked area variant for compositional time series")]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Suggestions come ranked, each with a one-line reason — useful for
|
|
102
|
+
debugging or for showing the user *why* a chart was picked.
|
|
103
|
+
|
|
104
|
+
You can also pass an `intent` to override the rules:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
plotify.auto(df, x="region", y="sales", intent="distribution")
|
|
108
|
+
# → Violinplot
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Themes
|
|
112
|
+
|
|
113
|
+
`plotify.theme` controls the look of every chart on both backends.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import plotify
|
|
117
|
+
|
|
118
|
+
plotify.theme.get_current().name # "publication" — applied automatically
|
|
119
|
+
plotify.theme.set("none") # opt out, use library defaults
|
|
120
|
+
plotify.theme.register(plotify.theme.Theme(name="brand", palette=("#FF1493", "#00CED1")))
|
|
121
|
+
plotify.theme.set("brand")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Package structure
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
plotify/
|
|
128
|
+
├── base.py # BasePlot — backend dispatch + save
|
|
129
|
+
├── numerical/ # Boxplot, DensityPlot, Violinplot, ScatterPlot, ConnectedScatterPlot
|
|
130
|
+
├── categorical/ # BarPlot, PieChart, Treemap, Sunburst, Venn, Dendrogram, etc. (12)
|
|
131
|
+
├── num_cat/ # GroupedBarPlot, StackedBarPlot, GroupedScatter, BoxPlotByGroup
|
|
132
|
+
├── timeseries/ # LineChart, AreaChart, StackedAreaChart, StreamGraph
|
|
133
|
+
├── network/ # NetworkDiagram, ChordDiagram, SankeyDiagram, ArcDiagram, HierarchicalEdgeBundling
|
|
134
|
+
└── maps/ # ChoroplethMap, BubbleMap, HexbinMap, Cartogram, ConnectionMap
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Installation
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install plotify-charts # PyPI distribution name
|
|
141
|
+
pip install plotify-charts[maps] # adds geopandas for ChoroplethMap's seaborn path
|
|
142
|
+
pip install plotify-charts[full] # all optional extras
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The Python import name is `plotify` regardless of which install variant
|
|
146
|
+
you pick:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
import plotify
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If you've cloned the repo for development, install with Poetry instead:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
poetry install --with dev --extras full
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Usage
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
import pandas as pd
|
|
162
|
+
from plotify.numerical import Boxplot
|
|
163
|
+
from plotify.categorical import BarPlot, PieChart
|
|
164
|
+
from plotify.timeseries import LineChart
|
|
165
|
+
from plotify.network import SankeyDiagram
|
|
166
|
+
|
|
167
|
+
df = pd.DataFrame({"cat": list("AAABBB"), "val": [1, 2, 3, 4, 5, 6]})
|
|
168
|
+
|
|
169
|
+
# Seaborn/Matplotlib backend → static image.
|
|
170
|
+
Boxplot(df, x="cat", y="val", backend="seaborn").save_plot("box.png")
|
|
171
|
+
|
|
172
|
+
# Plotly backend → interactive HTML (or static image via kaleido).
|
|
173
|
+
BarPlot(df, x="cat", y="val", backend="plotly").save_plot("bar.html")
|
|
174
|
+
PieChart(df, names="cat", values="val", backend="plotly").save_plot("pie.html")
|
|
175
|
+
|
|
176
|
+
# Sankey flow with explicit source/target/value lists.
|
|
177
|
+
SankeyDiagram(
|
|
178
|
+
source=[0, 1, 0],
|
|
179
|
+
target=[2, 2, 3],
|
|
180
|
+
value=[8, 4, 2],
|
|
181
|
+
labels=["A", "B", "C", "D"],
|
|
182
|
+
backend="plotly",
|
|
183
|
+
).save_plot("sankey.html")
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Every plot class accepts `backend="seaborn"` (default) or `backend="plotly"`.
|
|
187
|
+
A few classes only support one backend — `WordCloudPlot`, `VennDiagram`,
|
|
188
|
+
`CircularPacking`, `StreamGraph`, `ChordDiagram`, `ArcDiagram`,
|
|
189
|
+
`HierarchicalEdgeBundling`, and `Cartogram` are Seaborn-only because Plotly
|
|
190
|
+
has no native equivalent. Requesting an unsupported backend raises a
|
|
191
|
+
`ValueError` at construction time.
|
|
192
|
+
|
|
193
|
+
## Chart catalogue (all implemented)
|
|
194
|
+
|
|
195
|
+
| Category | Classes |
|
|
196
|
+
|---|---|
|
|
197
|
+
| Numerical | `Boxplot`, `DensityPlot`, `Violinplot`, `ScatterPlot`, `ConnectedScatterPlot` |
|
|
198
|
+
| Categoric | `BarPlot`, `LollipopChart`, `RadarChart`, `ParallelCoordinates`, `WordCloudPlot`, `PieChart`, `DoughnutChart`, `Treemap`, `CircularPacking`, `SunburstDiagram`, `VennDiagram`, `Dendrogram` |
|
|
199
|
+
| Num & Cat | `GroupedBarPlot`, `StackedBarPlot`, `GroupedScatter`, `BoxPlotByGroup` |
|
|
200
|
+
| Time series | `LineChart`, `AreaChart`, `StackedAreaChart`, `StreamGraph` |
|
|
201
|
+
| Network | `NetworkDiagram`, `ChordDiagram`, `SankeyDiagram`, `ArcDiagram`, `HierarchicalEdgeBundling` |
|
|
202
|
+
| Maps | `ChoroplethMap`, `BubbleMap`, `HexbinMap`, `Cartogram`, `ConnectionMap` |
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
Run the test suite:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
poetry run pytest
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The notebooks under [`notebooks/`](notebooks/) are **generated** from
|
|
213
|
+
[`scripts/build_notebooks.py`](scripts/build_notebooks.py) — please don't
|
|
214
|
+
hand-edit them. After changing an API or a chart class, rebuild and
|
|
215
|
+
re-execute in a single step:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
python scripts/build_notebooks.py --execute
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The `--execute` flag runs each notebook via `jupyter nbconvert` so the
|
|
222
|
+
rendered outputs are embedded in the committed `.ipynb` files. The script
|
|
223
|
+
sets `PYTHONPATH` to the repo root automatically, so it works without
|
|
224
|
+
pip-installing the package.
|
|
225
|
+
|
|
226
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
plotify/__init__.py,sha256=5Xs7gFJR_VbxAsEPibwPyNYbsTjOxnXm4nmywAvMzlo,2247
|
|
2
|
+
plotify/_inference.py,sha256=tJWgEQsh32Pwb08aey80hr-_InjKT0ADbXh2y5cQt6M,4493
|
|
3
|
+
plotify/auto.py,sha256=hjiYl2goa_5hw4Yf-bYOb329XKl2bg5MfupVY4LEBb4,11319
|
|
4
|
+
plotify/base.py,sha256=VhHINAOTC0SzOTRswGiLKrkr067gBq-vE-oG5OjUxgY,9233
|
|
5
|
+
plotify/categorical/__init__.py,sha256=gFzanek260zDQQmXymtJzijSToX43KpwxXKo3NowjK0,1243
|
|
6
|
+
plotify/categorical/bar_plot.py,sha256=gFSPf1v-XwleOKRY8iDDqoSv_Ne4nSV7Gk3UQD5YcGU,3317
|
|
7
|
+
plotify/categorical/circular_packing.py,sha256=QfK6qF_z2gTWVijJYdB3vxo74vJ6nDpRPvfenSvoCwA,3166
|
|
8
|
+
plotify/categorical/dendrogram.py,sha256=8BSlBdlOEupOHeyuWsF8iR8zTHSpmwesgZTo1Byp2aI,3520
|
|
9
|
+
plotify/categorical/doughnut_chart.py,sha256=ZVVNv5zK9MEdwzd4vc1H5-cXj7viqbM0kueNfSSA2r0,3060
|
|
10
|
+
plotify/categorical/lollipop_chart.py,sha256=KnvdwX2Yu6fh_4G-QvFMtBN8EIthpa6FvQQdLjAsi-0,4923
|
|
11
|
+
plotify/categorical/parallel_coordinates.py,sha256=_26xwEafaTcB7WsSuPEZhRmTU2snam5Ggc75nPKk2V0,2782
|
|
12
|
+
plotify/categorical/pie_chart.py,sha256=iXLB9OCa3VSIYlHK4hLeR8jDp7dshXAmbAxIpK98Y0I,2663
|
|
13
|
+
plotify/categorical/radar_chart.py,sha256=EPLgk9WRwgEP2kVH8_W3M0-gaNdvSje6QIL8WtJ0Jd8,3605
|
|
14
|
+
plotify/categorical/sunburst_diagram.py,sha256=Um--BlJ_6J5YQPS0x-SE3gtmUyThZVQebuLz7bCfQWI,3394
|
|
15
|
+
plotify/categorical/treemap.py,sha256=mLo3PW8Ebl8g5wKq_iC09GYUo6wDS2eJS6ftC8p2tcc,3726
|
|
16
|
+
plotify/categorical/venn_diagram.py,sha256=0hA7VTUZ64kLICwHtJbAYncb-8LecOSgjk5-Lc77kj0,2565
|
|
17
|
+
plotify/categorical/word_cloud.py,sha256=m6rgwsta_is53sGRcH7SsDkb_JqXkNMB22QIQ3USG3A,3296
|
|
18
|
+
plotify/maps/__init__.py,sha256=mX_4aGOcGo1mYnFA_wRzb6cJEeQolw9-_w_bnQ1o0gc,480
|
|
19
|
+
plotify/maps/bubble_map.py,sha256=6m534i_7WWiIK8_DBNSSSdNrw1hgb3r2kB_boqedVz4,3075
|
|
20
|
+
plotify/maps/cartogram.py,sha256=f5tyhqKws81EPZVeoBGqRmMZDZGoangGjel8k3QqHlQ,3763
|
|
21
|
+
plotify/maps/choropleth_map.py,sha256=RbelK0svakpTrmBgveMYxAu9uY088uiOeTrnaE_h6pE,3175
|
|
22
|
+
plotify/maps/connection_map.py,sha256=Pdu9PQaxg8XoYunDbtgOUJ4GvNv4kr74fbQ38ye_9LY,3588
|
|
23
|
+
plotify/maps/hexbin_map.py,sha256=QwPCnnHZpghFzxOLgLQbZZY3zKM8N6uxMA7hTZH6LSo,2582
|
|
24
|
+
plotify/network/__init__.py,sha256=gUS5tYB-IwSSxxzjavRasEjwYt8MfrDV9DEhnakrkR8,578
|
|
25
|
+
plotify/network/arc_diagram.py,sha256=Uf0NXBeM8afRG9kZJ2poGAOcMCwczpaG5177SWhoGTw,3675
|
|
26
|
+
plotify/network/chord_diagram.py,sha256=Ont1rbylvM5nY7GXpeQJuDNo40S1NjSyFRvM7-qW0Zc,3873
|
|
27
|
+
plotify/network/hierarchical_edge_bundling.py,sha256=wxEdUExZdZNViXkQ33QfkO8f0JHMP0911kHCpMC_xOY,4510
|
|
28
|
+
plotify/network/network_diagram.py,sha256=1ENs431W9XuPegt9vtd0XkGBV0Ee4xYnC1qQ-4Ww5LE,5248
|
|
29
|
+
plotify/network/sankey_diagram.py,sha256=75Gv3q6LnLx67jc6n53QZ1dVy5zW6VcbJ-cgjX_Jm-A,9185
|
|
30
|
+
plotify/num_cat/__init__.py,sha256=Pfyzdkhl38FDR9OzG4dkStxbKldZJYDqZcVlIKmfWmA,500
|
|
31
|
+
plotify/num_cat/box_plot_by_group.py,sha256=cJ2XPzVPOieCAKYSkUtKomujyjIbeMhvMNWljr3A8Ok,2892
|
|
32
|
+
plotify/num_cat/grouped_bar_plot.py,sha256=81PhUSTMHbC7Ouy2hXJGvN7Gutsk--l_hUSpfoNgdek,2829
|
|
33
|
+
plotify/num_cat/grouped_scatter.py,sha256=kaeACXsJgGblkxWIC0yM6pUQETyua0eJegSzl0E4F9M,2716
|
|
34
|
+
plotify/num_cat/stacked_bar_plot.py,sha256=q-4b4sz-pPihODMCNbY2RIB8udo0kiZhSghJvCnbv4g,3238
|
|
35
|
+
plotify/numerical/__init__.py,sha256=Te1pUqX2V0nj_BVUAkVNu3xF-j-XSskQsNCiTjx8yKs,548
|
|
36
|
+
plotify/numerical/boxplot.py,sha256=BHZg2YeFQTeywHdxOjABweNs6zrQPRsZdUrolut_N0E,5056
|
|
37
|
+
plotify/numerical/connected_scatter_plot.py,sha256=WB_FNNijG0arVXXlgK0QPJ7NJJuSbdRDa9_JU4cwJMo,3780
|
|
38
|
+
plotify/numerical/density_plot.py,sha256=GQKggjuDPUwiLdhGqDfYqHdklcOgysnqkwlBkP96Zfw,5511
|
|
39
|
+
plotify/numerical/scatter_plot.py,sha256=3PDz-18FEF1bNVNhIINc9ULUaHqPZFsICAw47ppVoSc,4434
|
|
40
|
+
plotify/numerical/violin_plot.py,sha256=bD5JqUDQLIY8T9eOpYv_X2jUhV7T_fMG3sQReRaEi_g,3900
|
|
41
|
+
plotify/theme.py,sha256=ArutlYwQ4w8mDdKSEe4iNGozyRl0KtObbS_dKlGUgj4,9204
|
|
42
|
+
plotify/timeseries/__init__.py,sha256=y2Bh4R9_FJ53flI0iFdOEBwfwMfQtRSdo51Tr2mMw8Q,420
|
|
43
|
+
plotify/timeseries/area_chart.py,sha256=rguHg6pUSN9CPMqe17cWJmSjlQL74AeL9afnQZu2Bkk,2242
|
|
44
|
+
plotify/timeseries/line_chart.py,sha256=5iPoYY3EsXypvljZDiofmhq5p8ndD-B3ua1A8z05pGU,2839
|
|
45
|
+
plotify/timeseries/stacked_area_chart.py,sha256=e8BJ-iRJRvlDtyu4n-F1kNRmN7nMzwk3RukvoF0YqZA,3850
|
|
46
|
+
plotify/timeseries/stream_graph.py,sha256=nPbrTTgwezIWcYlPUVrh5J62coDqb0Am-QveSkEoH5E,3391
|
|
47
|
+
plotify_charts-0.1.0.dist-info/LICENSE,sha256=KmwLkS0KF5zZGqLt8xt5T1msdJo6vvvtntYiGF7bFVw,1094
|
|
48
|
+
plotify_charts-0.1.0.dist-info/METADATA,sha256=PJo_8hDLSi14jx5qQZtj_h8OxkcN5GhPpko61o1rNec,8523
|
|
49
|
+
plotify_charts-0.1.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
50
|
+
plotify_charts-0.1.0.dist-info/RECORD,,
|