MatplotLibAPI 4.0.2__py3-none-any.whl → 4.0.3__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.
- MatplotLibAPI/__init__.py +3 -4
- MatplotLibAPI/accessor.py +56 -168
- MatplotLibAPI/area.py +3 -4
- MatplotLibAPI/bar.py +3 -4
- MatplotLibAPI/base_plot.py +60 -3
- MatplotLibAPI/box_violin.py +2 -3
- MatplotLibAPI/bubble.py +80 -13
- MatplotLibAPI/composite.py +233 -16
- MatplotLibAPI/heatmap.py +7 -10
- MatplotLibAPI/histogram.py +2 -6
- MatplotLibAPI/network/constants.py +1 -0
- MatplotLibAPI/network/core.py +0 -2
- MatplotLibAPI/pie.py +2 -3
- MatplotLibAPI/pivot.py +9 -11
- MatplotLibAPI/table.py +1 -3
- MatplotLibAPI/timeserie.py +2 -2
- MatplotLibAPI/types.py +6 -0
- MatplotLibAPI/waffle.py +1 -3
- MatplotLibAPI/word_cloud.py +1 -3
- {matplotlibapi-4.0.2.dist-info → matplotlibapi-4.0.3.dist-info}/METADATA +2 -2
- matplotlibapi-4.0.3.dist-info/RECORD +35 -0
- MatplotLibAPI/typing.py +0 -9
- MatplotLibAPI/utils.py +0 -111
- matplotlibapi-4.0.2.dist-info/RECORD +0 -36
- {matplotlibapi-4.0.2.dist-info → matplotlibapi-4.0.3.dist-info}/WHEEL +0 -0
- {matplotlibapi-4.0.2.dist-info → matplotlibapi-4.0.3.dist-info}/entry_points.txt +0 -0
- {matplotlibapi-4.0.2.dist-info → matplotlibapi-4.0.3.dist-info}/licenses/LICENSE +0 -0
MatplotLibAPI/__init__.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Public API and pandas accessor for MatplotLibAPI."""
|
|
2
2
|
|
|
3
|
-
from . import
|
|
4
|
-
from .
|
|
5
|
-
from .bubble import Bubble
|
|
3
|
+
from .accessor import DataFrameAccessor
|
|
4
|
+
from .types import CorrelationMethod
|
|
6
5
|
|
|
7
|
-
__all__ = ["
|
|
6
|
+
__all__ = ["DataFrameAccessor", "CorrelationMethod"]
|
MatplotLibAPI/accessor.py
CHANGED
|
@@ -10,7 +10,6 @@ from matplotlib.axes import Axes
|
|
|
10
10
|
from matplotlib.figure import Figure
|
|
11
11
|
from pandas.api.extensions import register_dataframe_accessor
|
|
12
12
|
|
|
13
|
-
from .base_plot import BasePlot
|
|
14
13
|
from .style_template import (
|
|
15
14
|
FIG_SIZE,
|
|
16
15
|
AREA_STYLE_TEMPLATE,
|
|
@@ -21,148 +20,13 @@ from .style_template import (
|
|
|
21
20
|
TREEMAP_STYLE_TEMPLATE,
|
|
22
21
|
StyleTemplate,
|
|
23
22
|
)
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
from .types import CorrelationMethod
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
27
|
import plotly.graph_objects as go
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def _heatmap_imports() -> tuple[StyleTemplate, Any, Any, Any, Any]:
|
|
31
|
-
from .heatmap import (
|
|
32
|
-
HEATMAP_STYLE_TEMPLATE,
|
|
33
|
-
aplot_correlation_matrix,
|
|
34
|
-
aplot_heatmap,
|
|
35
|
-
fplot_correlation_matrix,
|
|
36
|
-
fplot_heatmap,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
HEATMAP_STYLE_TEMPLATE,
|
|
41
|
-
aplot_correlation_matrix,
|
|
42
|
-
aplot_heatmap,
|
|
43
|
-
fplot_correlation_matrix,
|
|
44
|
-
fplot_heatmap,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def _network_imports() -> tuple[StyleTemplate, Any, Any, Any, Any, Any, Any]:
|
|
49
|
-
from .network import (
|
|
50
|
-
NETWORK_STYLE_TEMPLATE,
|
|
51
|
-
aplot_network,
|
|
52
|
-
aplot_network_node,
|
|
53
|
-
aplot_network_components,
|
|
54
|
-
fplot_network,
|
|
55
|
-
fplot_network_node,
|
|
56
|
-
fplot_network_components,
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
NETWORK_STYLE_TEMPLATE,
|
|
61
|
-
aplot_network,
|
|
62
|
-
aplot_network_node,
|
|
63
|
-
aplot_network_components,
|
|
64
|
-
fplot_network,
|
|
65
|
-
fplot_network_node,
|
|
66
|
-
fplot_network_components,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def _wordcloud_imports() -> tuple[StyleTemplate, Any, Any]:
|
|
71
|
-
from .word_cloud import WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud, fplot_wordcloud
|
|
72
|
-
|
|
73
|
-
return WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud, fplot_wordcloud
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def _sankey_imports() -> tuple[StyleTemplate, Any]:
|
|
77
|
-
from .sankey import SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
78
|
-
|
|
79
|
-
return SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def aplot_histogram(*args: Any, **kwargs: Any) -> Axes:
|
|
83
|
-
from .histogram import aplot_histogram as _aplot_histogram
|
|
84
|
-
|
|
85
|
-
return _aplot_histogram(*args, **kwargs)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def fplot_histogram(*args: Any, **kwargs: Any) -> Figure:
|
|
89
|
-
from .histogram import fplot_histogram as _fplot_histogram
|
|
90
|
-
|
|
91
|
-
return _fplot_histogram(*args, **kwargs)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def aplot_pie_donut(*args: Any, **kwargs: Any) -> Axes:
|
|
95
|
-
from .pie import aplot_pie as _aplot_pie_donut
|
|
96
|
-
|
|
97
|
-
return _aplot_pie_donut(*args, **kwargs)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def fplot_pie_donut(*args: Any, **kwargs: Any) -> Figure:
|
|
101
|
-
from .pie import fplot_pie as _fplot_pie_donut
|
|
102
|
-
|
|
103
|
-
return _fplot_pie_donut(*args, **kwargs)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def aplot_table(*args: Any, **kwargs: Any) -> Axes:
|
|
107
|
-
from .table import aplot_table as _aplot_table
|
|
108
|
-
|
|
109
|
-
return _aplot_table(*args, **kwargs)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def fplot_table(*args: Any, **kwargs: Any) -> Figure:
|
|
113
|
-
from .table import fplot_table as _fplot_table
|
|
114
|
-
|
|
115
|
-
return _fplot_table(*args, **kwargs)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def aplot_timeserie(*args: Any, **kwargs: Any) -> Axes:
|
|
119
|
-
from .timeserie import aplot_timeserie as _aplot_timeserie
|
|
120
|
-
|
|
121
|
-
return _aplot_timeserie(*args, **kwargs)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def fplot_timeserie(*args: Any, **kwargs: Any) -> Figure:
|
|
125
|
-
from .timeserie import fplot_timeserie as _fplot_timeserie
|
|
126
|
-
|
|
127
|
-
return _fplot_timeserie(*args, **kwargs)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def aplot_waffle(*args: Any, **kwargs: Any) -> Axes:
|
|
131
|
-
from .waffle import aplot_waffle as _aplot_waffle
|
|
132
|
-
|
|
133
|
-
return _aplot_waffle(*args, **kwargs)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def fplot_waffle(*args: Any, **kwargs: Any) -> Figure:
|
|
137
|
-
from .waffle import fplot_waffle as _fplot_waffle
|
|
138
|
-
|
|
139
|
-
return _fplot_waffle(*args, **kwargs)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def fplot_treemap(*args: Any, **kwargs: Any) -> go.Figure:
|
|
143
|
-
from .treemap import fplot_treemap as _fplot_treemap
|
|
144
|
-
|
|
145
|
-
return _fplot_treemap(*args, **kwargs)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def fplot_sunburst(*args: Any, **kwargs: Any) -> go.Figure:
|
|
149
|
-
from .sunburst import fplot_sunburst as _fplot_sunburst
|
|
150
|
-
|
|
151
|
-
return _fplot_sunburst(*args, **kwargs)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def plot_composite_bubble(*args: Any, **kwargs: Any) -> Figure:
|
|
155
|
-
from .composite import plot_composite_bubble as _plot_composite_bubble
|
|
156
|
-
|
|
157
|
-
return _plot_composite_bubble(*args, **kwargs)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def plot_composite_treemap(*args: Any, **kwargs: Any) -> Optional[go.Figure]:
|
|
161
|
-
from .composite import plot_composite_treemap as _plot_composite_treemap
|
|
162
|
-
|
|
163
|
-
return _plot_composite_treemap(*args, **kwargs)
|
|
164
|
-
|
|
165
|
-
|
|
166
30
|
@register_dataframe_accessor("mpl")
|
|
167
31
|
class DataFrameAccessor:
|
|
168
32
|
"""Expose MatplotLibAPI plotting helpers as a pandas accessor.
|
|
@@ -490,7 +354,9 @@ class DataFrameAccessor:
|
|
|
490
354
|
Axes
|
|
491
355
|
The Matplotlib axes object with the histogram.
|
|
492
356
|
"""
|
|
493
|
-
|
|
357
|
+
from .histogram import aplot_histogram as _aplot_histogram
|
|
358
|
+
|
|
359
|
+
return _aplot_histogram(
|
|
494
360
|
pd_df=self._obj,
|
|
495
361
|
column=column,
|
|
496
362
|
bins=bins,
|
|
@@ -531,7 +397,9 @@ class DataFrameAccessor:
|
|
|
531
397
|
Figure
|
|
532
398
|
The new Matplotlib figure with the histogram.
|
|
533
399
|
"""
|
|
534
|
-
|
|
400
|
+
from .histogram import fplot_histogram as _fplot_histogram
|
|
401
|
+
|
|
402
|
+
return _fplot_histogram(
|
|
535
403
|
pd_df=self._obj,
|
|
536
404
|
column=column,
|
|
537
405
|
bins=bins,
|
|
@@ -844,7 +712,9 @@ class DataFrameAccessor:
|
|
|
844
712
|
Axes
|
|
845
713
|
The Matplotlib axes object with the pie or donut chart.
|
|
846
714
|
"""
|
|
847
|
-
|
|
715
|
+
from .pie import aplot_pie as _aplot_pie_donut
|
|
716
|
+
|
|
717
|
+
return _aplot_pie_donut(
|
|
848
718
|
pd_df=self._obj,
|
|
849
719
|
category=category,
|
|
850
720
|
value=value,
|
|
@@ -885,7 +755,9 @@ class DataFrameAccessor:
|
|
|
885
755
|
Figure
|
|
886
756
|
The new Matplotlib figure with the pie or donut chart.
|
|
887
757
|
"""
|
|
888
|
-
|
|
758
|
+
from .pie import fplot_pie as _fplot_pie_donut
|
|
759
|
+
|
|
760
|
+
return _fplot_pie_donut(
|
|
889
761
|
pd_df=self._obj,
|
|
890
762
|
category=category,
|
|
891
763
|
value=value,
|
|
@@ -926,7 +798,9 @@ class DataFrameAccessor:
|
|
|
926
798
|
Axes
|
|
927
799
|
The Matplotlib axes object with the waffle chart.
|
|
928
800
|
"""
|
|
929
|
-
|
|
801
|
+
from .waffle import aplot_waffle as _aplot_waffle
|
|
802
|
+
|
|
803
|
+
return _aplot_waffle(
|
|
930
804
|
pd_df=self._obj,
|
|
931
805
|
category=category,
|
|
932
806
|
value=value,
|
|
@@ -967,7 +841,9 @@ class DataFrameAccessor:
|
|
|
967
841
|
Figure
|
|
968
842
|
The new Matplotlib figure with the waffle chart.
|
|
969
843
|
"""
|
|
970
|
-
|
|
844
|
+
from .waffle import fplot_waffle as _fplot_waffle
|
|
845
|
+
|
|
846
|
+
return _fplot_waffle(
|
|
971
847
|
pd_df=self._obj,
|
|
972
848
|
category=category,
|
|
973
849
|
value=value,
|
|
@@ -1005,7 +881,7 @@ class DataFrameAccessor:
|
|
|
1005
881
|
go.Figure
|
|
1006
882
|
The Plotly Sankey figure.
|
|
1007
883
|
"""
|
|
1008
|
-
|
|
884
|
+
from .sankey import SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
1009
885
|
|
|
1010
886
|
return fplot_sankey(
|
|
1011
887
|
pd_df=self._obj,
|
|
@@ -1013,7 +889,7 @@ class DataFrameAccessor:
|
|
|
1013
889
|
target=target,
|
|
1014
890
|
value=value,
|
|
1015
891
|
title=title,
|
|
1016
|
-
style=style or
|
|
892
|
+
style=style or SANKEY_STYLE_TEMPLATE,
|
|
1017
893
|
)
|
|
1018
894
|
|
|
1019
895
|
def aplot_table(
|
|
@@ -1050,7 +926,9 @@ class DataFrameAccessor:
|
|
|
1050
926
|
Axes
|
|
1051
927
|
The Matplotlib axes object with the plot.
|
|
1052
928
|
"""
|
|
1053
|
-
|
|
929
|
+
from .table import aplot_table as _aplot_table
|
|
930
|
+
|
|
931
|
+
return _aplot_table(
|
|
1054
932
|
pd_df=self._obj,
|
|
1055
933
|
cols=cols,
|
|
1056
934
|
title=title,
|
|
@@ -1095,7 +973,9 @@ class DataFrameAccessor:
|
|
|
1095
973
|
Figure
|
|
1096
974
|
The new Matplotlib figure with the table.
|
|
1097
975
|
"""
|
|
1098
|
-
|
|
976
|
+
from .table import fplot_table as _fplot_table
|
|
977
|
+
|
|
978
|
+
return _fplot_table(
|
|
1099
979
|
pd_df=self._obj,
|
|
1100
980
|
cols=cols,
|
|
1101
981
|
title=title,
|
|
@@ -1149,7 +1029,9 @@ class DataFrameAccessor:
|
|
|
1149
1029
|
Axes
|
|
1150
1030
|
The Matplotlib axes object with the plot.
|
|
1151
1031
|
"""
|
|
1152
|
-
|
|
1032
|
+
from .timeserie import aplot_timeserie as _aplot_timeserie
|
|
1033
|
+
|
|
1034
|
+
return _aplot_timeserie(
|
|
1153
1035
|
pd_df=self._obj,
|
|
1154
1036
|
label=label,
|
|
1155
1037
|
x=x,
|
|
@@ -1206,7 +1088,9 @@ class DataFrameAccessor:
|
|
|
1206
1088
|
Figure
|
|
1207
1089
|
The new Matplotlib figure with the plot.
|
|
1208
1090
|
"""
|
|
1209
|
-
|
|
1091
|
+
from .timeserie import fplot_timeserie as _fplot_timeserie
|
|
1092
|
+
|
|
1093
|
+
return _fplot_timeserie(
|
|
1210
1094
|
pd_df=self._obj,
|
|
1211
1095
|
label=label,
|
|
1212
1096
|
x=x,
|
|
@@ -1257,14 +1141,14 @@ class DataFrameAccessor:
|
|
|
1257
1141
|
Axes
|
|
1258
1142
|
The Matplotlib axes object with the plot.
|
|
1259
1143
|
"""
|
|
1260
|
-
|
|
1144
|
+
from .word_cloud import WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud
|
|
1261
1145
|
|
|
1262
1146
|
return aplot_wordcloud(
|
|
1263
1147
|
pd_df=self._obj,
|
|
1264
1148
|
text_column=text_column,
|
|
1265
1149
|
weight_column=weight_column,
|
|
1266
1150
|
title=title,
|
|
1267
|
-
style=style or
|
|
1151
|
+
style=style or WORDCLOUD_STYLE_TEMPLATE,
|
|
1268
1152
|
max_words=max_words,
|
|
1269
1153
|
stopwords=stopwords,
|
|
1270
1154
|
random_state=random_state,
|
|
@@ -1308,14 +1192,14 @@ class DataFrameAccessor:
|
|
|
1308
1192
|
Figure
|
|
1309
1193
|
The new Matplotlib figure with the plot.
|
|
1310
1194
|
"""
|
|
1311
|
-
|
|
1195
|
+
from .word_cloud import WORDCLOUD_STYLE_TEMPLATE, fplot_wordcloud
|
|
1312
1196
|
|
|
1313
1197
|
return fplot_wordcloud(
|
|
1314
1198
|
pd_df=self._obj,
|
|
1315
1199
|
text_column=text_column,
|
|
1316
1200
|
weight_column=weight_column,
|
|
1317
1201
|
title=title,
|
|
1318
|
-
style=style or
|
|
1202
|
+
style=style or WORDCLOUD_STYLE_TEMPLATE,
|
|
1319
1203
|
max_words=max_words,
|
|
1320
1204
|
stopwords=stopwords,
|
|
1321
1205
|
random_state=random_state,
|
|
@@ -1377,17 +1261,19 @@ class DataFrameAccessor:
|
|
|
1377
1261
|
kwargs: Dict[str, Any] = {}
|
|
1378
1262
|
if layout_seed is not None:
|
|
1379
1263
|
kwargs["layout_seed"] = layout_seed
|
|
1264
|
+
from .network import (
|
|
1265
|
+
NETWORK_STYLE_TEMPLATE,
|
|
1266
|
+
aplot_network_node as _aplot_network_node,
|
|
1267
|
+
)
|
|
1380
1268
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
return aplot_network_node(
|
|
1269
|
+
return _aplot_network_node(
|
|
1384
1270
|
pd_df=self._obj,
|
|
1385
1271
|
node=node,
|
|
1386
1272
|
edge_source_col=edge_source_col,
|
|
1387
1273
|
edge_target_col=edge_target_col,
|
|
1388
1274
|
edge_weight_col=edge_weight_col,
|
|
1389
1275
|
title=title,
|
|
1390
|
-
style=style or
|
|
1276
|
+
style=style or NETWORK_STYLE_TEMPLATE,
|
|
1391
1277
|
ax=ax,
|
|
1392
1278
|
**kwargs,
|
|
1393
1279
|
)
|
|
@@ -1437,9 +1323,7 @@ class DataFrameAccessor:
|
|
|
1437
1323
|
if layout_seed is not None:
|
|
1438
1324
|
kwargs["layout_seed"] = layout_seed
|
|
1439
1325
|
|
|
1440
|
-
|
|
1441
|
-
_network_imports()
|
|
1442
|
-
)
|
|
1326
|
+
from .network import NETWORK_STYLE_TEMPLATE, aplot_network_components
|
|
1443
1327
|
|
|
1444
1328
|
aplot_network_components(
|
|
1445
1329
|
pd_df=self._obj,
|
|
@@ -1449,7 +1333,7 @@ class DataFrameAccessor:
|
|
|
1449
1333
|
sort_by=sort_by,
|
|
1450
1334
|
ascending=ascending,
|
|
1451
1335
|
title=title,
|
|
1452
|
-
style=style or
|
|
1336
|
+
style=style or NETWORK_STYLE_TEMPLATE,
|
|
1453
1337
|
axes=axes,
|
|
1454
1338
|
**kwargs,
|
|
1455
1339
|
)
|
|
@@ -1510,7 +1394,7 @@ class DataFrameAccessor:
|
|
|
1510
1394
|
if layout_seed is not None:
|
|
1511
1395
|
kwargs["layout_seed"] = layout_seed
|
|
1512
1396
|
|
|
1513
|
-
|
|
1397
|
+
from .network import NETWORK_STYLE_TEMPLATE, fplot_network_node
|
|
1514
1398
|
|
|
1515
1399
|
return fplot_network_node(
|
|
1516
1400
|
pd_df=self._obj,
|
|
@@ -1519,7 +1403,7 @@ class DataFrameAccessor:
|
|
|
1519
1403
|
edge_target_col=edge_target_col,
|
|
1520
1404
|
edge_weight_col=edge_weight_col,
|
|
1521
1405
|
title=title,
|
|
1522
|
-
style=style or
|
|
1406
|
+
style=style or NETWORK_STYLE_TEMPLATE,
|
|
1523
1407
|
figsize=figsize,
|
|
1524
1408
|
**kwargs,
|
|
1525
1409
|
)
|
|
@@ -1575,9 +1459,7 @@ class DataFrameAccessor:
|
|
|
1575
1459
|
if layout_seed is not None:
|
|
1576
1460
|
kwargs["layout_seed"] = layout_seed
|
|
1577
1461
|
|
|
1578
|
-
|
|
1579
|
-
_network_imports()
|
|
1580
|
-
)
|
|
1462
|
+
from .network import NETWORK_STYLE_TEMPLATE, fplot_network_components
|
|
1581
1463
|
|
|
1582
1464
|
return fplot_network_components(
|
|
1583
1465
|
pd_df=self._obj,
|
|
@@ -1585,7 +1467,7 @@ class DataFrameAccessor:
|
|
|
1585
1467
|
edge_target_col=edge_target_col,
|
|
1586
1468
|
edge_weight_col=edge_weight_col,
|
|
1587
1469
|
title=title,
|
|
1588
|
-
style=style or
|
|
1470
|
+
style=style or NETWORK_STYLE_TEMPLATE,
|
|
1589
1471
|
figsize=figsize,
|
|
1590
1472
|
n_cols=n_cols,
|
|
1591
1473
|
**kwargs,
|
|
@@ -1631,6 +1513,8 @@ class DataFrameAccessor:
|
|
|
1631
1513
|
go.Figure
|
|
1632
1514
|
The Plotly figure with the treemap.
|
|
1633
1515
|
"""
|
|
1516
|
+
from .treemap import fplot_treemap
|
|
1517
|
+
|
|
1634
1518
|
return fplot_treemap(
|
|
1635
1519
|
pd_df=self._obj,
|
|
1636
1520
|
path=path,
|
|
@@ -1680,6 +1564,8 @@ class DataFrameAccessor:
|
|
|
1680
1564
|
go.Figure
|
|
1681
1565
|
The Plotly figure with the sunburst chart.
|
|
1682
1566
|
"""
|
|
1567
|
+
from .sunburst import fplot_sunburst
|
|
1568
|
+
|
|
1683
1569
|
return fplot_sunburst(
|
|
1684
1570
|
pd_df=self._obj,
|
|
1685
1571
|
labels=labels,
|
|
@@ -1729,6 +1615,8 @@ class DataFrameAccessor:
|
|
|
1729
1615
|
go.Figure, optional
|
|
1730
1616
|
The Plotly figure with the composite treemap, or None if the input data is empty.
|
|
1731
1617
|
"""
|
|
1618
|
+
from .composite import plot_composite_treemap
|
|
1619
|
+
|
|
1732
1620
|
pd_dfs: Dict[str, pd.DataFrame] = {}
|
|
1733
1621
|
for path in paths:
|
|
1734
1622
|
pd_dfs[path] = self._obj
|
MatplotLibAPI/area.py
CHANGED
|
@@ -14,7 +14,6 @@ from .style_template import (
|
|
|
14
14
|
string_formatter,
|
|
15
15
|
validate_dataframe,
|
|
16
16
|
)
|
|
17
|
-
from .utils import _get_axis, _merge_kwargs, create_fig
|
|
18
17
|
|
|
19
18
|
__all__ = ["AREA_STYLE_TEMPLATE", "aplot_area", "fplot_area"]
|
|
20
19
|
|
|
@@ -83,7 +82,7 @@ class AreaChart(BasePlot):
|
|
|
83
82
|
"alpha": 0.7,
|
|
84
83
|
"ax": plot_ax,
|
|
85
84
|
}
|
|
86
|
-
pivot_df.plot(**
|
|
85
|
+
pivot_df.plot(**BasePlot.merge_kwargs(plot_kwargs, kwargs))
|
|
87
86
|
|
|
88
87
|
legend = plot_ax.get_legend()
|
|
89
88
|
if legend is not None:
|
|
@@ -101,7 +100,7 @@ class AreaChart(BasePlot):
|
|
|
101
100
|
"color": style.font_color,
|
|
102
101
|
"alpha": 0.4,
|
|
103
102
|
}
|
|
104
|
-
merged_fill_between_kwargs =
|
|
103
|
+
merged_fill_between_kwargs = BasePlot.merge_kwargs(fill_between_kwargs, kwargs)
|
|
105
104
|
|
|
106
105
|
plot_ax.fill_between(
|
|
107
106
|
sorted_df[self.x],
|
|
@@ -137,7 +136,7 @@ class AreaChart(BasePlot):
|
|
|
137
136
|
"""
|
|
138
137
|
if not style:
|
|
139
138
|
style = AREA_STYLE_TEMPLATE
|
|
140
|
-
plot_ax =
|
|
139
|
+
plot_ax = BasePlot.get_axis(ax)
|
|
141
140
|
plot_ax.set_facecolor(style.background_color)
|
|
142
141
|
|
|
143
142
|
if self.label:
|
MatplotLibAPI/bar.py
CHANGED
|
@@ -15,7 +15,6 @@ from .style_template import (
|
|
|
15
15
|
string_formatter,
|
|
16
16
|
validate_dataframe,
|
|
17
17
|
)
|
|
18
|
-
from .utils import _get_axis, _merge_kwargs
|
|
19
18
|
|
|
20
19
|
__all__ = ["DISTRIBUTION_STYLE_TEMPLATE", "aplot_bar", "fplot_bar"]
|
|
21
20
|
|
|
@@ -74,7 +73,7 @@ class BarChart(BasePlot):
|
|
|
74
73
|
Axes
|
|
75
74
|
The Matplotlib Axes object containing the plot.
|
|
76
75
|
"""
|
|
77
|
-
plot_ax =
|
|
76
|
+
plot_ax = BasePlot.get_axis(ax)
|
|
78
77
|
|
|
79
78
|
if self.group:
|
|
80
79
|
pivot_df = self._obj.pivot_table(
|
|
@@ -89,7 +88,7 @@ class BarChart(BasePlot):
|
|
|
89
88
|
"ax": plot_ax,
|
|
90
89
|
"alpha": 0.85,
|
|
91
90
|
}
|
|
92
|
-
pivot_df.plot(**
|
|
91
|
+
pivot_df.plot(**BasePlot.merge_kwargs(plot_kwargs, kwargs))
|
|
93
92
|
else:
|
|
94
93
|
barplot_kwargs: dict[str, Any] = {
|
|
95
94
|
"data": self._obj,
|
|
@@ -98,7 +97,7 @@ class BarChart(BasePlot):
|
|
|
98
97
|
"palette": style.palette,
|
|
99
98
|
"ax": plot_ax,
|
|
100
99
|
}
|
|
101
|
-
sns.barplot(**
|
|
100
|
+
sns.barplot(**BasePlot.merge_kwargs(barplot_kwargs, kwargs))
|
|
102
101
|
|
|
103
102
|
plot_ax.set_facecolor(style.background_color)
|
|
104
103
|
plot_ax.set_xlabel(string_formatter(self.category))
|
MatplotLibAPI/base_plot.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Abstract base class for all plot types."""
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from typing import Any, Optional, Tuple, cast
|
|
4
|
+
from typing import Any, Optional, Tuple, cast, Dict
|
|
5
5
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
import matplotlib.pyplot as plt
|
|
@@ -85,9 +85,38 @@ class BasePlot(ABC):
|
|
|
85
85
|
|
|
86
86
|
return fig
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
def filter(
|
|
89
|
+
self, order_by: str, sort_ascending: bool = False, max_values: int = 10
|
|
90
|
+
) -> pd.DataFrame:
|
|
91
|
+
"""Filter and sort the underlying DataFrame.
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
order_by : str
|
|
96
|
+
Column name to sort by.
|
|
97
|
+
sort_ascending : bool, optional
|
|
98
|
+
Sort direction. Defaults to False (descending).
|
|
99
|
+
max_values : int, optional
|
|
100
|
+
Maximum number of rows to return. Defaults to 10.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
pd.DataFrame
|
|
105
|
+
Filtered, sorted DataFrame head by the provided limits.
|
|
106
|
+
|
|
107
|
+
Raises
|
|
108
|
+
------
|
|
109
|
+
ValueError
|
|
110
|
+
If the `order_by` column is not present in the DataFrame.
|
|
111
|
+
"""
|
|
112
|
+
if order_by not in self._obj.columns:
|
|
113
|
+
raise ValueError(f"Column '{order_by}' not found in DataFrame")
|
|
114
|
+
df = self._obj.sort_values(by=order_by, ascending=sort_ascending)
|
|
115
|
+
return df.head(max_values)
|
|
116
|
+
|
|
117
|
+
@staticmethod
|
|
89
118
|
def create_fig(
|
|
90
|
-
|
|
119
|
+
figsize: Tuple[float, float], style: StyleTemplate
|
|
91
120
|
) -> Tuple[Figure, Axes]:
|
|
92
121
|
"""Create a figure and axis configured from the provided style.
|
|
93
122
|
|
|
@@ -110,3 +139,31 @@ class BasePlot(ABC):
|
|
|
110
139
|
fig.set_edgecolor(style.background_color)
|
|
111
140
|
ax.set_facecolor(style.background_color)
|
|
112
141
|
return fig, ax
|
|
142
|
+
|
|
143
|
+
@staticmethod
|
|
144
|
+
def get_axis(ax: Optional[Axes] = None) -> Axes:
|
|
145
|
+
"""Return a Matplotlib axes, defaulting to the current one."""
|
|
146
|
+
return ax if ax is not None else plt.gca()
|
|
147
|
+
|
|
148
|
+
@staticmethod
|
|
149
|
+
def merge_kwargs(
|
|
150
|
+
defaults: Dict[str, Any], overrides: Optional[Dict[str, Any]] = None
|
|
151
|
+
) -> Dict[str, Any]:
|
|
152
|
+
"""Return a merged kwargs dictionary with caller overrides taking precedence.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
defaults : dict[str, Any]
|
|
157
|
+
Default keyword arguments.
|
|
158
|
+
overrides : dict[str, Any], optional
|
|
159
|
+
Caller-provided keyword arguments that should override defaults.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
dict[str, Any]
|
|
164
|
+
Merged keyword arguments.
|
|
165
|
+
"""
|
|
166
|
+
merged = defaults.copy()
|
|
167
|
+
if overrides:
|
|
168
|
+
merged.update(overrides)
|
|
169
|
+
return merged
|
MatplotLibAPI/box_violin.py
CHANGED
|
@@ -15,7 +15,6 @@ from .style_template import (
|
|
|
15
15
|
string_formatter,
|
|
16
16
|
validate_dataframe,
|
|
17
17
|
)
|
|
18
|
-
from .utils import _get_axis, _merge_kwargs
|
|
19
18
|
|
|
20
19
|
__all__ = ["DISTRIBUTION_STYLE_TEMPLATE", "aplot_box_violin", "fplot_box_violin"]
|
|
21
20
|
|
|
@@ -74,7 +73,7 @@ class BoxViolinPlot(BasePlot):
|
|
|
74
73
|
"""
|
|
75
74
|
if not style:
|
|
76
75
|
style = DISTRIBUTION_STYLE_TEMPLATE
|
|
77
|
-
plot_ax =
|
|
76
|
+
plot_ax = BasePlot.get_axis(ax)
|
|
78
77
|
|
|
79
78
|
common_kwargs = {
|
|
80
79
|
"data": self._obj,
|
|
@@ -89,7 +88,7 @@ class BoxViolinPlot(BasePlot):
|
|
|
89
88
|
"legend": False,
|
|
90
89
|
"ax": plot_ax,
|
|
91
90
|
}
|
|
92
|
-
merged_plot_kwargs =
|
|
91
|
+
merged_plot_kwargs = BasePlot.merge_kwargs(plot_kwargs, kwargs)
|
|
93
92
|
|
|
94
93
|
if self.violin:
|
|
95
94
|
sns.violinplot(**merged_plot_kwargs)
|