MatplotLibAPI 3.2.21__py3-none-any.whl → 4.0.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.
- MatplotLibAPI/__init__.py +4 -86
- MatplotLibAPI/accessor.py +519 -196
- MatplotLibAPI/area.py +177 -0
- MatplotLibAPI/bar.py +185 -0
- MatplotLibAPI/base_plot.py +88 -0
- MatplotLibAPI/box_violin.py +180 -0
- MatplotLibAPI/bubble.py +568 -0
- MatplotLibAPI/{Composite.py → composite.py} +127 -106
- MatplotLibAPI/heatmap.py +223 -0
- MatplotLibAPI/histogram.py +170 -0
- MatplotLibAPI/mcp/__init__.py +17 -0
- MatplotLibAPI/mcp/metadata.py +90 -0
- MatplotLibAPI/mcp/renderers.py +45 -0
- MatplotLibAPI/mcp_server.py +626 -0
- MatplotLibAPI/network/__init__.py +28 -0
- MatplotLibAPI/network/constants.py +22 -0
- MatplotLibAPI/network/core.py +1360 -0
- MatplotLibAPI/network/plot.py +597 -0
- MatplotLibAPI/network/scaling.py +56 -0
- MatplotLibAPI/pie.py +154 -0
- MatplotLibAPI/pivot.py +274 -0
- MatplotLibAPI/sankey.py +99 -0
- MatplotLibAPI/{StyleTemplate.py → style_template.py} +27 -22
- MatplotLibAPI/sunburst.py +139 -0
- MatplotLibAPI/{Table.py → table.py} +112 -87
- MatplotLibAPI/{Timeserie.py → timeserie.py} +98 -42
- MatplotLibAPI/{Treemap.py → treemap.py} +43 -55
- MatplotLibAPI/typing.py +12 -0
- MatplotLibAPI/{_visualization_utils.py → utils.py} +7 -13
- MatplotLibAPI/waffle.py +173 -0
- MatplotLibAPI/word_cloud.py +489 -0
- {matplotlibapi-3.2.21.dist-info → matplotlibapi-4.0.0.dist-info}/METADATA +98 -9
- matplotlibapi-4.0.0.dist-info/RECORD +36 -0
- {matplotlibapi-3.2.21.dist-info → matplotlibapi-4.0.0.dist-info}/WHEEL +1 -1
- matplotlibapi-4.0.0.dist-info/entry_points.txt +2 -0
- MatplotLibAPI/Area.py +0 -80
- MatplotLibAPI/Bar.py +0 -83
- MatplotLibAPI/BoxViolin.py +0 -75
- MatplotLibAPI/Bubble.py +0 -458
- MatplotLibAPI/Heatmap.py +0 -121
- MatplotLibAPI/Histogram.py +0 -73
- MatplotLibAPI/Network.py +0 -989
- MatplotLibAPI/Pie.py +0 -70
- MatplotLibAPI/Pivot.py +0 -134
- MatplotLibAPI/Sankey.py +0 -46
- MatplotLibAPI/Sunburst.py +0 -89
- MatplotLibAPI/Waffle.py +0 -86
- MatplotLibAPI/Wordcloud.py +0 -373
- MatplotLibAPI/_typing.py +0 -17
- matplotlibapi-3.2.21.dist-info/RECORD +0 -26
- {matplotlibapi-3.2.21.dist-info → matplotlibapi-4.0.0.dist-info}/licenses/LICENSE +0 -0
MatplotLibAPI/accessor.py
CHANGED
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
"""Pandas accessor exposing MatplotLibAPI plotting helpers."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
|
|
4
6
|
|
|
5
7
|
import numpy as np
|
|
6
8
|
import pandas as pd
|
|
7
|
-
import plotly.graph_objects as go
|
|
8
9
|
from matplotlib.axes import Axes
|
|
9
10
|
from matplotlib.figure import Figure
|
|
10
11
|
from pandas.api.extensions import register_dataframe_accessor
|
|
11
12
|
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
14
|
-
from .BoxViolin import aplot_box_violin, fplot_box_violin
|
|
15
|
-
from .Bubble import BUBBLE_STYLE_TEMPLATE, aplot_bubble, fplot_bubble
|
|
16
|
-
from .Composite import plot_composite_bubble, plot_composite_treemap
|
|
17
|
-
from .Heatmap import (
|
|
18
|
-
HEATMAP_STYLE_TEMPLATE,
|
|
19
|
-
aplot_correlation_matrix,
|
|
20
|
-
aplot_heatmap,
|
|
21
|
-
fplot_correlation_matrix,
|
|
22
|
-
fplot_heatmap,
|
|
23
|
-
)
|
|
24
|
-
from .Histogram import aplot_histogram_kde, fplot_histogram_kde
|
|
25
|
-
from .Network import (
|
|
26
|
-
NETWORK_STYLE_TEMPLATE,
|
|
27
|
-
aplot_network,
|
|
28
|
-
aplot_network_components,
|
|
29
|
-
fplot_network_components,
|
|
30
|
-
fplot_network,
|
|
31
|
-
)
|
|
32
|
-
from .Pie import aplot_pie_donut, fplot_pie_donut
|
|
33
|
-
from .Sankey import SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
34
|
-
from .StyleTemplate import (
|
|
13
|
+
from .base_plot import BasePlot
|
|
14
|
+
from .style_template import (
|
|
35
15
|
FIG_SIZE,
|
|
36
16
|
AREA_STYLE_TEMPLATE,
|
|
37
17
|
DISTRIBUTION_STYLE_TEMPLATE,
|
|
@@ -41,19 +21,198 @@ from .StyleTemplate import (
|
|
|
41
21
|
TREEMAP_STYLE_TEMPLATE,
|
|
42
22
|
StyleTemplate,
|
|
43
23
|
)
|
|
44
|
-
from .
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
from .typing import CorrelationMethod
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
import plotly.graph_objects as go
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _bubble_imports() -> tuple[StyleTemplate, type]:
|
|
31
|
+
from .bubble import BUBBLE_STYLE_TEMPLATE, Bubble
|
|
32
|
+
|
|
33
|
+
return BUBBLE_STYLE_TEMPLATE, Bubble
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _heatmap_imports() -> tuple[StyleTemplate, Any, Any, Any, Any]:
|
|
37
|
+
from .heatmap import (
|
|
38
|
+
HEATMAP_STYLE_TEMPLATE,
|
|
39
|
+
aplot_correlation_matrix,
|
|
40
|
+
aplot_heatmap,
|
|
41
|
+
fplot_correlation_matrix,
|
|
42
|
+
fplot_heatmap,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
HEATMAP_STYLE_TEMPLATE,
|
|
47
|
+
aplot_correlation_matrix,
|
|
48
|
+
aplot_heatmap,
|
|
49
|
+
fplot_correlation_matrix,
|
|
50
|
+
fplot_heatmap,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _network_imports() -> tuple[StyleTemplate, Any, Any, Any, Any, Any, Any]:
|
|
55
|
+
from .network import (
|
|
56
|
+
NETWORK_STYLE_TEMPLATE,
|
|
57
|
+
aplot_network,
|
|
58
|
+
aplot_network_node,
|
|
59
|
+
aplot_network_components,
|
|
60
|
+
fplot_network,
|
|
61
|
+
fplot_network_node,
|
|
62
|
+
fplot_network_components,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
NETWORK_STYLE_TEMPLATE,
|
|
67
|
+
aplot_network,
|
|
68
|
+
aplot_network_node,
|
|
69
|
+
aplot_network_components,
|
|
70
|
+
fplot_network,
|
|
71
|
+
fplot_network_node,
|
|
72
|
+
fplot_network_components,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _wordcloud_imports() -> tuple[StyleTemplate, Any, Any]:
|
|
77
|
+
from .word_cloud import WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud, fplot_wordcloud
|
|
78
|
+
|
|
79
|
+
return WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud, fplot_wordcloud
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _sankey_imports() -> tuple[StyleTemplate, Any]:
|
|
83
|
+
from .sankey import SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
84
|
+
|
|
85
|
+
return SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def aplot_area(*args: Any, **kwargs: Any) -> Axes:
|
|
89
|
+
from .area import aplot_area as _aplot_area
|
|
90
|
+
|
|
91
|
+
return _aplot_area(*args, **kwargs)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def fplot_area(*args: Any, **kwargs: Any) -> Figure:
|
|
95
|
+
from .area import fplot_area as _fplot_area
|
|
96
|
+
|
|
97
|
+
return _fplot_area(*args, **kwargs)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def aplot_bar(*args: Any, **kwargs: Any) -> Axes:
|
|
101
|
+
from .bar import aplot_bar as _aplot_bar
|
|
102
|
+
|
|
103
|
+
return _aplot_bar(*args, **kwargs)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def fplot_bar(*args: Any, **kwargs: Any) -> Figure:
|
|
107
|
+
from .bar import fplot_bar as _fplot_bar
|
|
108
|
+
|
|
109
|
+
return _fplot_bar(*args, **kwargs)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def aplot_box_violin(*args: Any, **kwargs: Any) -> Axes:
|
|
113
|
+
from .box_violin import aplot_box_violin as _aplot_box_violin
|
|
114
|
+
|
|
115
|
+
return _aplot_box_violin(*args, **kwargs)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def fplot_box_violin(*args: Any, **kwargs: Any) -> Figure:
|
|
119
|
+
from .box_violin import fplot_box_violin as _fplot_box_violin
|
|
120
|
+
|
|
121
|
+
return _fplot_box_violin(*args, **kwargs)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def aplot_histogram(*args: Any, **kwargs: Any) -> Axes:
|
|
125
|
+
from .histogram import aplot_histogram as _aplot_histogram
|
|
126
|
+
|
|
127
|
+
return _aplot_histogram(*args, **kwargs)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def fplot_histogram(*args: Any, **kwargs: Any) -> Figure:
|
|
131
|
+
from .histogram import fplot_histogram as _fplot_histogram
|
|
132
|
+
|
|
133
|
+
return _fplot_histogram(*args, **kwargs)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def aplot_pie_donut(*args: Any, **kwargs: Any) -> Axes:
|
|
137
|
+
from .pie import aplot_pie as _aplot_pie_donut
|
|
138
|
+
|
|
139
|
+
return _aplot_pie_donut(*args, **kwargs)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def fplot_pie_donut(*args: Any, **kwargs: Any) -> Figure:
|
|
143
|
+
from .pie import fplot_pie as _fplot_pie_donut
|
|
144
|
+
|
|
145
|
+
return _fplot_pie_donut(*args, **kwargs)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def aplot_table(*args: Any, **kwargs: Any) -> Axes:
|
|
149
|
+
from .table import aplot_table as _aplot_table
|
|
150
|
+
|
|
151
|
+
return _aplot_table(*args, **kwargs)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def fplot_table(*args: Any, **kwargs: Any) -> Figure:
|
|
155
|
+
from .table import fplot_table as _fplot_table
|
|
156
|
+
|
|
157
|
+
return _fplot_table(*args, **kwargs)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def aplot_timeserie(*args: Any, **kwargs: Any) -> Axes:
|
|
161
|
+
from .timeserie import aplot_timeserie as _aplot_timeserie
|
|
162
|
+
|
|
163
|
+
return _aplot_timeserie(*args, **kwargs)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def fplot_timeserie(*args: Any, **kwargs: Any) -> Figure:
|
|
167
|
+
from .timeserie import fplot_timeserie as _fplot_timeserie
|
|
168
|
+
|
|
169
|
+
return _fplot_timeserie(*args, **kwargs)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def aplot_waffle(*args: Any, **kwargs: Any) -> Axes:
|
|
173
|
+
from .waffle import aplot_waffle as _aplot_waffle
|
|
174
|
+
|
|
175
|
+
return _aplot_waffle(*args, **kwargs)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def fplot_waffle(*args: Any, **kwargs: Any) -> Figure:
|
|
179
|
+
from .waffle import fplot_waffle as _fplot_waffle
|
|
180
|
+
|
|
181
|
+
return _fplot_waffle(*args, **kwargs)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def fplot_treemap(*args: Any, **kwargs: Any) -> go.Figure:
|
|
185
|
+
from .treemap import fplot_treemap as _fplot_treemap
|
|
186
|
+
|
|
187
|
+
return _fplot_treemap(*args, **kwargs)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def fplot_sunburst(*args: Any, **kwargs: Any) -> go.Figure:
|
|
191
|
+
from .sunburst import fplot_sunburst as _fplot_sunburst
|
|
192
|
+
|
|
193
|
+
return _fplot_sunburst(*args, **kwargs)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def plot_composite_bubble(*args: Any, **kwargs: Any) -> Figure:
|
|
197
|
+
from .composite import plot_composite_bubble as _plot_composite_bubble
|
|
198
|
+
|
|
199
|
+
return _plot_composite_bubble(*args, **kwargs)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def plot_composite_treemap(*args: Any, **kwargs: Any) -> Optional[go.Figure]:
|
|
203
|
+
from .composite import plot_composite_treemap as _plot_composite_treemap
|
|
204
|
+
|
|
205
|
+
return _plot_composite_treemap(*args, **kwargs)
|
|
51
206
|
|
|
52
207
|
|
|
53
208
|
@register_dataframe_accessor("mpl")
|
|
54
209
|
class DataFrameAccessor:
|
|
55
210
|
"""Expose MatplotLibAPI plotting helpers as a pandas accessor.
|
|
56
211
|
|
|
212
|
+
All plot methods follow the BasePlot interface pattern, providing both
|
|
213
|
+
aplot_* (plot on existing axes) and fplot_* (plot on new figure) variants
|
|
214
|
+
for consistency and ease of use.
|
|
215
|
+
|
|
57
216
|
Methods
|
|
58
217
|
-------
|
|
59
218
|
aplot_bubble
|
|
@@ -110,10 +269,14 @@ class DataFrameAccessor:
|
|
|
110
269
|
Plot a word cloud on a new figure.
|
|
111
270
|
aplot_network
|
|
112
271
|
Plot a network graph on a Matplotlib axes.
|
|
272
|
+
aplot_network_node
|
|
273
|
+
Plot the connected component for a specific node on a Matplotlib axes.
|
|
113
274
|
aplot_network_components
|
|
114
275
|
Plot connected components of a network graph on multiple axes.
|
|
115
276
|
fplot_network
|
|
116
277
|
Plot a network graph on a new figure.
|
|
278
|
+
fplot_network_node
|
|
279
|
+
Plot the connected component for a specific node on a new figure.
|
|
117
280
|
fplot_network_components
|
|
118
281
|
Plot connected components of a network graph on a new figure.
|
|
119
282
|
fplot_treemap
|
|
@@ -135,7 +298,7 @@ class DataFrameAccessor:
|
|
|
135
298
|
y: str,
|
|
136
299
|
z: str,
|
|
137
300
|
title: Optional[str] = None,
|
|
138
|
-
style: StyleTemplate =
|
|
301
|
+
style: Optional[StyleTemplate] = None,
|
|
139
302
|
max_values: int = 50,
|
|
140
303
|
center_to_mean: bool = False,
|
|
141
304
|
sort_by: Optional[str] = None,
|
|
@@ -180,18 +343,21 @@ class DataFrameAccessor:
|
|
|
180
343
|
Axes
|
|
181
344
|
The Matplotlib axes object with the plot.
|
|
182
345
|
"""
|
|
183
|
-
|
|
346
|
+
bubble_style_template, Bubble = _bubble_imports()
|
|
347
|
+
|
|
348
|
+
return Bubble(
|
|
184
349
|
pd_df=self._obj,
|
|
185
350
|
label=label,
|
|
186
351
|
x=x,
|
|
187
352
|
y=y,
|
|
188
353
|
z=z,
|
|
189
|
-
title=title,
|
|
190
|
-
style=style,
|
|
191
354
|
max_values=max_values,
|
|
192
355
|
center_to_mean=center_to_mean,
|
|
193
356
|
sort_by=sort_by,
|
|
194
357
|
ascending=ascending,
|
|
358
|
+
).aplot(
|
|
359
|
+
title=title,
|
|
360
|
+
style=style or bubble_style_template,
|
|
195
361
|
hline=hline,
|
|
196
362
|
vline=vline,
|
|
197
363
|
ax=ax,
|
|
@@ -204,7 +370,7 @@ class DataFrameAccessor:
|
|
|
204
370
|
y: str,
|
|
205
371
|
z: str,
|
|
206
372
|
title: Optional[str] = None,
|
|
207
|
-
style: StyleTemplate =
|
|
373
|
+
style: Optional[StyleTemplate] = None,
|
|
208
374
|
max_values: int = 50,
|
|
209
375
|
center_to_mean: bool = False,
|
|
210
376
|
sort_by: Optional[str] = None,
|
|
@@ -212,8 +378,6 @@ class DataFrameAccessor:
|
|
|
212
378
|
hline: bool = False,
|
|
213
379
|
vline: bool = False,
|
|
214
380
|
figsize: Tuple[float, float] = FIG_SIZE,
|
|
215
|
-
save_path: Optional[str] = None,
|
|
216
|
-
savefig_kwargs: Optional[Dict[str, Any]] = None,
|
|
217
381
|
) -> Figure:
|
|
218
382
|
"""Plot a bubble chart on a new figure.
|
|
219
383
|
|
|
@@ -251,14 +415,25 @@ class DataFrameAccessor:
|
|
|
251
415
|
Figure
|
|
252
416
|
The new Matplotlib figure with the plot.
|
|
253
417
|
"""
|
|
254
|
-
|
|
418
|
+
bubble_style_template, Bubble = _bubble_imports()
|
|
419
|
+
|
|
420
|
+
return Bubble(
|
|
255
421
|
pd_df=self._obj,
|
|
422
|
+
label=label,
|
|
423
|
+
x=x,
|
|
424
|
+
y=y,
|
|
425
|
+
z=z,
|
|
426
|
+
sort_by=sort_by,
|
|
427
|
+
ascending=ascending,
|
|
428
|
+
max_values=max_values,
|
|
429
|
+
center_to_mean=center_to_mean,
|
|
430
|
+
).fplot(
|
|
256
431
|
label=label,
|
|
257
432
|
x=x,
|
|
258
433
|
y=y,
|
|
259
434
|
z=z,
|
|
260
435
|
title=title,
|
|
261
|
-
style=style,
|
|
436
|
+
style=style or bubble_style_template,
|
|
262
437
|
max_values=max_values,
|
|
263
438
|
center_to_mean=center_to_mean,
|
|
264
439
|
sort_by=sort_by,
|
|
@@ -266,8 +441,6 @@ class DataFrameAccessor:
|
|
|
266
441
|
hline=hline,
|
|
267
442
|
vline=vline,
|
|
268
443
|
figsize=figsize,
|
|
269
|
-
save_path=save_path,
|
|
270
|
-
savefig_kwargs=savefig_kwargs,
|
|
271
444
|
)
|
|
272
445
|
|
|
273
446
|
def fplot_composite_bubble(
|
|
@@ -277,7 +450,7 @@ class DataFrameAccessor:
|
|
|
277
450
|
y: str,
|
|
278
451
|
z: str,
|
|
279
452
|
title: Optional[str] = None,
|
|
280
|
-
style: StyleTemplate =
|
|
453
|
+
style: Optional[StyleTemplate] = None,
|
|
281
454
|
max_values: int = 100,
|
|
282
455
|
center_to_mean: bool = False,
|
|
283
456
|
sort_by: Optional[str] = None,
|
|
@@ -319,6 +492,8 @@ class DataFrameAccessor:
|
|
|
319
492
|
Figure
|
|
320
493
|
The new Matplotlib figure with the composite plot.
|
|
321
494
|
"""
|
|
495
|
+
bubble_style_template, _ = _bubble_imports()
|
|
496
|
+
|
|
322
497
|
return plot_composite_bubble(
|
|
323
498
|
pd_df=self._obj,
|
|
324
499
|
label=label,
|
|
@@ -326,7 +501,7 @@ class DataFrameAccessor:
|
|
|
326
501
|
y=y,
|
|
327
502
|
z=z,
|
|
328
503
|
title=title,
|
|
329
|
-
style=style,
|
|
504
|
+
style=style or bubble_style_template,
|
|
330
505
|
max_values=max_values,
|
|
331
506
|
center_to_mean=center_to_mean,
|
|
332
507
|
sort_by=sort_by,
|
|
@@ -375,7 +550,7 @@ class DataFrameAccessor:
|
|
|
375
550
|
group=group,
|
|
376
551
|
stacked=stacked,
|
|
377
552
|
title=title,
|
|
378
|
-
style=style,
|
|
553
|
+
style=style or DISTRIBUTION_STYLE_TEMPLATE,
|
|
379
554
|
ax=ax,
|
|
380
555
|
)
|
|
381
556
|
|
|
@@ -455,7 +630,7 @@ class DataFrameAccessor:
|
|
|
455
630
|
Axes
|
|
456
631
|
The Matplotlib axes object with the histogram.
|
|
457
632
|
"""
|
|
458
|
-
return
|
|
633
|
+
return aplot_histogram(
|
|
459
634
|
pd_df=self._obj,
|
|
460
635
|
column=column,
|
|
461
636
|
bins=bins,
|
|
@@ -496,7 +671,7 @@ class DataFrameAccessor:
|
|
|
496
671
|
Figure
|
|
497
672
|
The new Matplotlib figure with the histogram.
|
|
498
673
|
"""
|
|
499
|
-
return
|
|
674
|
+
return fplot_histogram(
|
|
500
675
|
pd_df=self._obj,
|
|
501
676
|
column=column,
|
|
502
677
|
bins=bins,
|
|
@@ -594,7 +769,7 @@ class DataFrameAccessor:
|
|
|
594
769
|
y: str,
|
|
595
770
|
value: str,
|
|
596
771
|
title: Optional[str] = None,
|
|
597
|
-
style: StyleTemplate =
|
|
772
|
+
style: Optional[StyleTemplate] = None,
|
|
598
773
|
ax: Optional[Axes] = None,
|
|
599
774
|
) -> Axes:
|
|
600
775
|
"""Plot a heatmap for dense categorical combinations.
|
|
@@ -619,13 +794,15 @@ class DataFrameAccessor:
|
|
|
619
794
|
Axes
|
|
620
795
|
The Matplotlib axes object with the heatmap.
|
|
621
796
|
"""
|
|
797
|
+
heatmap_style_template, _, aplot_heatmap, _, _ = _heatmap_imports()
|
|
798
|
+
|
|
622
799
|
return aplot_heatmap(
|
|
623
800
|
pd_df=self._obj,
|
|
624
801
|
x=x,
|
|
625
802
|
y=y,
|
|
626
803
|
value=value,
|
|
627
804
|
title=title,
|
|
628
|
-
style=style,
|
|
805
|
+
style=style or DISTRIBUTION_STYLE_TEMPLATE,
|
|
629
806
|
ax=ax,
|
|
630
807
|
)
|
|
631
808
|
|
|
@@ -635,7 +812,7 @@ class DataFrameAccessor:
|
|
|
635
812
|
y: str,
|
|
636
813
|
value: str,
|
|
637
814
|
title: Optional[str] = None,
|
|
638
|
-
style: StyleTemplate =
|
|
815
|
+
style: Optional[StyleTemplate] = None,
|
|
639
816
|
figsize: Tuple[float, float] = FIG_SIZE,
|
|
640
817
|
) -> Figure:
|
|
641
818
|
"""Plot a heatmap on a new figure.
|
|
@@ -660,13 +837,15 @@ class DataFrameAccessor:
|
|
|
660
837
|
Figure
|
|
661
838
|
The new Matplotlib figure with the heatmap.
|
|
662
839
|
"""
|
|
840
|
+
heatmap_style_template, _, _, _, fplot_heatmap = _heatmap_imports()
|
|
841
|
+
|
|
663
842
|
return fplot_heatmap(
|
|
664
843
|
pd_df=self._obj,
|
|
665
844
|
x=x,
|
|
666
845
|
y=y,
|
|
667
846
|
value=value,
|
|
668
847
|
title=title,
|
|
669
|
-
style=style,
|
|
848
|
+
style=style or heatmap_style_template,
|
|
670
849
|
figsize=figsize,
|
|
671
850
|
)
|
|
672
851
|
|
|
@@ -675,7 +854,7 @@ class DataFrameAccessor:
|
|
|
675
854
|
columns: Optional[List[str]] = None,
|
|
676
855
|
method: CorrelationMethod = "pearson",
|
|
677
856
|
title: Optional[str] = None,
|
|
678
|
-
style: StyleTemplate =
|
|
857
|
+
style: Optional[StyleTemplate] = None,
|
|
679
858
|
ax: Optional[Axes] = None,
|
|
680
859
|
) -> Axes:
|
|
681
860
|
"""Plot a correlation matrix heatmap.
|
|
@@ -698,52 +877,17 @@ class DataFrameAccessor:
|
|
|
698
877
|
Axes
|
|
699
878
|
The Matplotlib axes object with the correlation matrix.
|
|
700
879
|
"""
|
|
880
|
+
heatmap_style_template, aplot_correlation_matrix, _, _, _ = _heatmap_imports()
|
|
881
|
+
|
|
701
882
|
return aplot_correlation_matrix(
|
|
702
883
|
pd_df=self._obj,
|
|
703
884
|
columns=columns,
|
|
704
885
|
method=method,
|
|
705
886
|
title=title,
|
|
706
|
-
style=style,
|
|
887
|
+
style=style or DISTRIBUTION_STYLE_TEMPLATE,
|
|
707
888
|
ax=ax,
|
|
708
889
|
)
|
|
709
890
|
|
|
710
|
-
def fplot_correlation_matrix(
|
|
711
|
-
self,
|
|
712
|
-
columns: Optional[List[str]] = None,
|
|
713
|
-
method: CorrelationMethod = "pearson",
|
|
714
|
-
title: Optional[str] = None,
|
|
715
|
-
style: StyleTemplate = HEATMAP_STYLE_TEMPLATE,
|
|
716
|
-
figsize: Tuple[float, float] = FIG_SIZE,
|
|
717
|
-
) -> Figure:
|
|
718
|
-
"""Plot a correlation matrix heatmap on a new figure.
|
|
719
|
-
|
|
720
|
-
Parameters
|
|
721
|
-
----------
|
|
722
|
-
columns : list[str], optional
|
|
723
|
-
Numeric columns to include. The default is ``None`` for all numeric columns.
|
|
724
|
-
method : CorrelationMethod, optional
|
|
725
|
-
Correlation method. The default is "pearson".
|
|
726
|
-
title : str, optional
|
|
727
|
-
Chart title.
|
|
728
|
-
style : StyleTemplate, optional
|
|
729
|
-
Styling template. The default is ``HEATMAP_STYLE_TEMPLATE``.
|
|
730
|
-
figsize : tuple[float, float], optional
|
|
731
|
-
Figure size. The default is FIG_SIZE.
|
|
732
|
-
|
|
733
|
-
Returns
|
|
734
|
-
-------
|
|
735
|
-
Figure
|
|
736
|
-
The new Matplotlib figure with the correlation matrix.
|
|
737
|
-
"""
|
|
738
|
-
return fplot_correlation_matrix(
|
|
739
|
-
pd_df=self._obj,
|
|
740
|
-
columns=columns,
|
|
741
|
-
method=method,
|
|
742
|
-
title=title,
|
|
743
|
-
style=style,
|
|
744
|
-
figsize=figsize,
|
|
745
|
-
)
|
|
746
|
-
|
|
747
891
|
def aplot_area(
|
|
748
892
|
self,
|
|
749
893
|
x: str,
|
|
@@ -1004,7 +1148,7 @@ class DataFrameAccessor:
|
|
|
1004
1148
|
target: str,
|
|
1005
1149
|
value: str,
|
|
1006
1150
|
title: Optional[str] = None,
|
|
1007
|
-
style: StyleTemplate =
|
|
1151
|
+
style: Optional[StyleTemplate] = None,
|
|
1008
1152
|
) -> go.Figure:
|
|
1009
1153
|
"""Plot a Sankey diagram for flow data.
|
|
1010
1154
|
|
|
@@ -1026,13 +1170,15 @@ class DataFrameAccessor:
|
|
|
1026
1170
|
go.Figure
|
|
1027
1171
|
The Plotly Sankey figure.
|
|
1028
1172
|
"""
|
|
1173
|
+
sankey_style_template, fplot_sankey = _sankey_imports()
|
|
1174
|
+
|
|
1029
1175
|
return fplot_sankey(
|
|
1030
1176
|
pd_df=self._obj,
|
|
1031
1177
|
source=source,
|
|
1032
1178
|
target=target,
|
|
1033
1179
|
value=value,
|
|
1034
1180
|
title=title,
|
|
1035
|
-
style=style,
|
|
1181
|
+
style=style or sankey_style_template,
|
|
1036
1182
|
)
|
|
1037
1183
|
|
|
1038
1184
|
def aplot_table(
|
|
@@ -1073,7 +1219,7 @@ class DataFrameAccessor:
|
|
|
1073
1219
|
pd_df=self._obj,
|
|
1074
1220
|
cols=cols,
|
|
1075
1221
|
title=title,
|
|
1076
|
-
style=style,
|
|
1222
|
+
style=style or TABLE_STYLE_TEMPLATE,
|
|
1077
1223
|
max_values=max_values,
|
|
1078
1224
|
sort_by=sort_by,
|
|
1079
1225
|
ascending=ascending,
|
|
@@ -1118,7 +1264,7 @@ class DataFrameAccessor:
|
|
|
1118
1264
|
pd_df=self._obj,
|
|
1119
1265
|
cols=cols,
|
|
1120
1266
|
title=title,
|
|
1121
|
-
style=style,
|
|
1267
|
+
style=style or TABLE_STYLE_TEMPLATE,
|
|
1122
1268
|
max_values=max_values,
|
|
1123
1269
|
sort_by=sort_by,
|
|
1124
1270
|
ascending=ascending,
|
|
@@ -1174,7 +1320,7 @@ class DataFrameAccessor:
|
|
|
1174
1320
|
x=x,
|
|
1175
1321
|
y=y,
|
|
1176
1322
|
title=title,
|
|
1177
|
-
style=style,
|
|
1323
|
+
style=style or TIMESERIE_STYLE_TEMPLATE,
|
|
1178
1324
|
max_values=max_values,
|
|
1179
1325
|
sort_by=sort_by,
|
|
1180
1326
|
ascending=ascending,
|
|
@@ -1231,7 +1377,7 @@ class DataFrameAccessor:
|
|
|
1231
1377
|
x=x,
|
|
1232
1378
|
y=y,
|
|
1233
1379
|
title=title,
|
|
1234
|
-
style=style,
|
|
1380
|
+
style=style or TIMESERIE_STYLE_TEMPLATE,
|
|
1235
1381
|
max_values=max_values,
|
|
1236
1382
|
sort_by=sort_by,
|
|
1237
1383
|
ascending=ascending,
|
|
@@ -1242,9 +1388,9 @@ class DataFrameAccessor:
|
|
|
1242
1388
|
def aplot_wordcloud(
|
|
1243
1389
|
self,
|
|
1244
1390
|
text_column: str,
|
|
1245
|
-
weight_column:
|
|
1391
|
+
weight_column: str,
|
|
1246
1392
|
title: Optional[str] = None,
|
|
1247
|
-
style: StyleTemplate =
|
|
1393
|
+
style: Optional[StyleTemplate] = None,
|
|
1248
1394
|
max_words: int = 50,
|
|
1249
1395
|
stopwords: Optional[List[str]] = None,
|
|
1250
1396
|
random_state: Optional[int] = None,
|
|
@@ -1276,12 +1422,14 @@ class DataFrameAccessor:
|
|
|
1276
1422
|
Axes
|
|
1277
1423
|
The Matplotlib axes object with the plot.
|
|
1278
1424
|
"""
|
|
1425
|
+
wordcloud_style_template, aplot_wordcloud, _ = _wordcloud_imports()
|
|
1426
|
+
|
|
1279
1427
|
return aplot_wordcloud(
|
|
1280
1428
|
pd_df=self._obj,
|
|
1281
1429
|
text_column=text_column,
|
|
1282
1430
|
weight_column=weight_column,
|
|
1283
1431
|
title=title,
|
|
1284
|
-
style=style,
|
|
1432
|
+
style=style or wordcloud_style_template,
|
|
1285
1433
|
max_words=max_words,
|
|
1286
1434
|
stopwords=stopwords,
|
|
1287
1435
|
random_state=random_state,
|
|
@@ -1291,9 +1439,9 @@ class DataFrameAccessor:
|
|
|
1291
1439
|
def fplot_wordcloud(
|
|
1292
1440
|
self,
|
|
1293
1441
|
text_column: str,
|
|
1294
|
-
weight_column:
|
|
1442
|
+
weight_column: str,
|
|
1295
1443
|
title: Optional[str] = None,
|
|
1296
|
-
style: StyleTemplate =
|
|
1444
|
+
style: Optional[StyleTemplate] = None,
|
|
1297
1445
|
max_words: int = 50,
|
|
1298
1446
|
stopwords: Optional[List[str]] = None,
|
|
1299
1447
|
random_state: Optional[int] = None,
|
|
@@ -1325,12 +1473,14 @@ class DataFrameAccessor:
|
|
|
1325
1473
|
Figure
|
|
1326
1474
|
The new Matplotlib figure with the plot.
|
|
1327
1475
|
"""
|
|
1476
|
+
wordcloud_style_template, _, fplot_wordcloud = _wordcloud_imports()
|
|
1477
|
+
|
|
1328
1478
|
return fplot_wordcloud(
|
|
1329
1479
|
pd_df=self._obj,
|
|
1330
1480
|
text_column=text_column,
|
|
1331
1481
|
weight_column=weight_column,
|
|
1332
1482
|
title=title,
|
|
1333
|
-
style=style,
|
|
1483
|
+
style=style or wordcloud_style_template,
|
|
1334
1484
|
max_words=max_words,
|
|
1335
1485
|
stopwords=stopwords,
|
|
1336
1486
|
random_state=random_state,
|
|
@@ -1339,36 +1489,104 @@ class DataFrameAccessor:
|
|
|
1339
1489
|
|
|
1340
1490
|
def aplot_network(
|
|
1341
1491
|
self,
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1492
|
+
edge_source_col: str = "source",
|
|
1493
|
+
edge_target_col: str = "target",
|
|
1494
|
+
edge_weight_col: str = "weight",
|
|
1345
1495
|
title: Optional[str] = None,
|
|
1346
|
-
style: StyleTemplate =
|
|
1347
|
-
|
|
1348
|
-
ascending: bool = False,
|
|
1349
|
-
node_list: Optional[List] = None,
|
|
1496
|
+
style: Optional[StyleTemplate] = None,
|
|
1497
|
+
layout_seed: Optional[int] = None,
|
|
1350
1498
|
ax: Optional[Axes] = None,
|
|
1351
1499
|
) -> Axes:
|
|
1352
1500
|
"""Plot a network graph on a Matplotlib axes.
|
|
1353
1501
|
|
|
1354
1502
|
Parameters
|
|
1355
1503
|
----------
|
|
1356
|
-
|
|
1504
|
+
node_col : str, optional
|
|
1505
|
+
Column for node identifiers. The default is "node".
|
|
1506
|
+
node_weight_col : str, optional
|
|
1507
|
+
Column for node weights. The default is "weight".
|
|
1508
|
+
edge_source_col : str, optional
|
|
1357
1509
|
Column for source nodes. The default is "source".
|
|
1358
|
-
|
|
1510
|
+
edge_target_col : str, optional
|
|
1359
1511
|
Column for target nodes. The default is "target".
|
|
1360
|
-
|
|
1512
|
+
edge_weight_col : str, optional
|
|
1361
1513
|
Column for edge weights. The default is "weight".
|
|
1514
|
+
sort_by : str, optional
|
|
1515
|
+
Column to sort by.
|
|
1516
|
+
ascending : bool, optional
|
|
1517
|
+
Sort order. The default is `False`.
|
|
1518
|
+
node_df : pd.DataFrame, optional
|
|
1519
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1362
1520
|
title : str, optional
|
|
1363
1521
|
Chart title.
|
|
1364
1522
|
style : StyleTemplate, optional
|
|
1365
1523
|
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1524
|
+
layout_seed : int, optional
|
|
1525
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1526
|
+
ax : Axes, optional
|
|
1527
|
+
Matplotlib axes to plot on. If None, uses the current axes.
|
|
1528
|
+
|
|
1529
|
+
Returns
|
|
1530
|
+
-------
|
|
1531
|
+
Axes
|
|
1532
|
+
The Matplotlib axes object with the plot.
|
|
1533
|
+
"""
|
|
1534
|
+
kwargs: Dict[str, Any] = {}
|
|
1535
|
+
if layout_seed is not None:
|
|
1536
|
+
kwargs["layout_seed"] = layout_seed
|
|
1537
|
+
|
|
1538
|
+
network_style_template, aplot_network, _, _, _, _, _ = _network_imports()
|
|
1539
|
+
|
|
1540
|
+
return aplot_network(
|
|
1541
|
+
pd_df=self._obj,
|
|
1542
|
+
edge_source_col=edge_source_col,
|
|
1543
|
+
edge_target_col=edge_target_col,
|
|
1544
|
+
edge_weight_col=edge_weight_col,
|
|
1545
|
+
title=title,
|
|
1546
|
+
style=style or network_style_template,
|
|
1547
|
+
ax=ax,
|
|
1548
|
+
**kwargs,
|
|
1549
|
+
)
|
|
1550
|
+
|
|
1551
|
+
def aplot_network_node(
|
|
1552
|
+
self,
|
|
1553
|
+
node: Any,
|
|
1554
|
+
edge_source_col: str = "source",
|
|
1555
|
+
edge_target_col: str = "target",
|
|
1556
|
+
edge_weight_col: str = "weight",
|
|
1557
|
+
layout_seed: Optional[int] = None,
|
|
1558
|
+
title: Optional[str] = None,
|
|
1559
|
+
style: Optional[StyleTemplate] = None,
|
|
1560
|
+
ax: Optional[Axes] = None,
|
|
1561
|
+
) -> Axes:
|
|
1562
|
+
"""Plot the connected component containing ``node``.
|
|
1563
|
+
|
|
1564
|
+
Parameters
|
|
1565
|
+
----------
|
|
1566
|
+
node : Any
|
|
1567
|
+
Node identifier whose component should be visualized.
|
|
1568
|
+
node_col : str, optional
|
|
1569
|
+
Column for node identifiers. The default is "node".
|
|
1570
|
+
node_weight_col : str, optional
|
|
1571
|
+
Column for node weights. The default is "weight".
|
|
1572
|
+
edge_source_col : str, optional
|
|
1573
|
+
Column for source nodes. The default is "source".
|
|
1574
|
+
edge_target_col : str, optional
|
|
1575
|
+
Column for target nodes. The default is "target".
|
|
1576
|
+
edge_weight_col : str, optional
|
|
1577
|
+
Column for edge weights. The default is "weight".
|
|
1366
1578
|
sort_by : str, optional
|
|
1367
1579
|
Column to sort by.
|
|
1368
1580
|
ascending : bool, optional
|
|
1369
1581
|
Sort order. The default is `False`.
|
|
1370
|
-
|
|
1371
|
-
|
|
1582
|
+
node_df : pd.DataFrame, optional
|
|
1583
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1584
|
+
layout_seed : int, optional
|
|
1585
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1586
|
+
title : str, optional
|
|
1587
|
+
Chart title. Defaults to the formatted node label when ``None``.
|
|
1588
|
+
style : StyleTemplate, optional
|
|
1589
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1372
1590
|
ax : Axes, optional
|
|
1373
1591
|
Matplotlib axes to plot on. If None, uses the current axes.
|
|
1374
1592
|
|
|
@@ -1376,100 +1594,192 @@ class DataFrameAccessor:
|
|
|
1376
1594
|
-------
|
|
1377
1595
|
Axes
|
|
1378
1596
|
The Matplotlib axes object with the plot.
|
|
1597
|
+
|
|
1598
|
+
Raises
|
|
1599
|
+
------
|
|
1600
|
+
ValueError
|
|
1601
|
+
If ``node`` is not present in the prepared graph.
|
|
1379
1602
|
"""
|
|
1380
|
-
|
|
1603
|
+
kwargs: Dict[str, Any] = {}
|
|
1604
|
+
if layout_seed is not None:
|
|
1605
|
+
kwargs["layout_seed"] = layout_seed
|
|
1606
|
+
|
|
1607
|
+
network_style_template, _, aplot_network_node, _, _, _, _ = _network_imports()
|
|
1608
|
+
|
|
1609
|
+
return aplot_network_node(
|
|
1381
1610
|
pd_df=self._obj,
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1611
|
+
node=node,
|
|
1612
|
+
edge_source_col=edge_source_col,
|
|
1613
|
+
edge_target_col=edge_target_col,
|
|
1614
|
+
edge_weight_col=edge_weight_col,
|
|
1385
1615
|
title=title,
|
|
1386
|
-
style=style,
|
|
1387
|
-
sort_by=sort_by,
|
|
1388
|
-
ascending=ascending,
|
|
1389
|
-
node_list=node_list,
|
|
1616
|
+
style=style or network_style_template,
|
|
1390
1617
|
ax=ax,
|
|
1618
|
+
**kwargs,
|
|
1391
1619
|
)
|
|
1392
1620
|
|
|
1393
1621
|
def aplot_network_components(
|
|
1394
1622
|
self,
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
title: Optional[str] = None,
|
|
1399
|
-
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1623
|
+
edge_source_col: str = "source",
|
|
1624
|
+
edge_target_col: str = "target",
|
|
1625
|
+
edge_weight_col: str = "weight",
|
|
1400
1626
|
sort_by: Optional[str] = None,
|
|
1401
1627
|
ascending: bool = False,
|
|
1402
|
-
|
|
1628
|
+
title: Optional[str] = None,
|
|
1629
|
+
style: Optional[StyleTemplate] = None,
|
|
1630
|
+
layout_seed: Optional[int] = None,
|
|
1403
1631
|
axes: Optional[np.ndarray] = None,
|
|
1404
1632
|
) -> None:
|
|
1405
1633
|
"""Plot connected components of a network graph on multiple axes.
|
|
1406
1634
|
|
|
1407
1635
|
Parameters
|
|
1408
1636
|
----------
|
|
1409
|
-
|
|
1637
|
+
node_col : str, optional
|
|
1638
|
+
Column for node identifiers. The default is "node".
|
|
1639
|
+
node_weight_col : str, optional
|
|
1640
|
+
Column for node weights. The default is "weight".
|
|
1641
|
+
edge_source_col : str, optional
|
|
1410
1642
|
Column for source nodes. The default is "source".
|
|
1411
|
-
|
|
1643
|
+
edge_target_col : str, optional
|
|
1412
1644
|
Column for target nodes. The default is "target".
|
|
1413
|
-
|
|
1645
|
+
edge_weight_col : str, optional
|
|
1414
1646
|
Column for edge weights. The default is "weight".
|
|
1415
|
-
title : str, optional
|
|
1416
|
-
Chart title.
|
|
1417
|
-
style : StyleTemplate, optional
|
|
1418
|
-
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1419
1647
|
sort_by : str, optional
|
|
1420
1648
|
Column to sort by.
|
|
1421
1649
|
ascending : bool, optional
|
|
1422
1650
|
Sort order. The default is `False`.
|
|
1423
|
-
|
|
1424
|
-
|
|
1651
|
+
node_df : pd.DataFrame, optional
|
|
1652
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1653
|
+
title : str, optional
|
|
1654
|
+
Chart title.
|
|
1655
|
+
style : StyleTemplate, optional
|
|
1656
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1657
|
+
layout_seed : int, optional
|
|
1658
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1425
1659
|
axes : np.ndarray, optional
|
|
1426
1660
|
Numpy array of Matplotlib axes to plot on. If None, new axes are created.
|
|
1427
1661
|
"""
|
|
1662
|
+
kwargs: Dict[str, Any] = {}
|
|
1663
|
+
if layout_seed is not None:
|
|
1664
|
+
kwargs["layout_seed"] = layout_seed
|
|
1665
|
+
|
|
1666
|
+
network_style_template, _, _, aplot_network_components, _, _, _ = (
|
|
1667
|
+
_network_imports()
|
|
1668
|
+
)
|
|
1669
|
+
|
|
1428
1670
|
aplot_network_components(
|
|
1429
1671
|
pd_df=self._obj,
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
title=title,
|
|
1434
|
-
style=style,
|
|
1672
|
+
edge_source_col=edge_source_col,
|
|
1673
|
+
edge_target_col=edge_target_col,
|
|
1674
|
+
edge_weight_col=edge_weight_col,
|
|
1435
1675
|
sort_by=sort_by,
|
|
1436
1676
|
ascending=ascending,
|
|
1437
|
-
|
|
1677
|
+
title=title,
|
|
1678
|
+
style=style or network_style_template,
|
|
1438
1679
|
axes=axes,
|
|
1680
|
+
**kwargs,
|
|
1439
1681
|
)
|
|
1440
1682
|
|
|
1441
1683
|
def fplot_network(
|
|
1442
1684
|
self,
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1685
|
+
edge_source_col: str = "source",
|
|
1686
|
+
edge_target_col: str = "target",
|
|
1687
|
+
edge_weight_col: str = "weight",
|
|
1446
1688
|
title: Optional[str] = None,
|
|
1447
|
-
style: StyleTemplate =
|
|
1448
|
-
|
|
1449
|
-
ascending: bool = False,
|
|
1450
|
-
node_list: Optional[List] = None,
|
|
1689
|
+
style: Optional[StyleTemplate] = None,
|
|
1690
|
+
layout_seed: Optional[int] = None,
|
|
1451
1691
|
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1452
1692
|
) -> Figure:
|
|
1453
1693
|
"""Plot a network graph on a new figure.
|
|
1454
1694
|
|
|
1455
1695
|
Parameters
|
|
1456
1696
|
----------
|
|
1457
|
-
|
|
1697
|
+
node_col : str, optional
|
|
1698
|
+
Column for node identifiers. The default is "node".
|
|
1699
|
+
node_weight_col : str, optional
|
|
1700
|
+
Column for node weights. The default is "weight".
|
|
1701
|
+
edge_source_col : str, optional
|
|
1458
1702
|
Column for source nodes. The default is "source".
|
|
1459
|
-
|
|
1703
|
+
edge_target_col : str, optional
|
|
1460
1704
|
Column for target nodes. The default is "target".
|
|
1461
|
-
|
|
1705
|
+
edge_weight_col : str, optional
|
|
1462
1706
|
Column for edge weights. The default is "weight".
|
|
1707
|
+
sort_by : str, optional
|
|
1708
|
+
Column to sort by.
|
|
1709
|
+
ascending : bool, optional
|
|
1710
|
+
Sort order. The default is `False`.
|
|
1711
|
+
node_df : pd.DataFrame, optional
|
|
1712
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1463
1713
|
title : str, optional
|
|
1464
1714
|
Chart title.
|
|
1465
1715
|
style : StyleTemplate, optional
|
|
1466
1716
|
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1717
|
+
layout_seed : int, optional
|
|
1718
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1719
|
+
figsize : tuple[float, float], optional
|
|
1720
|
+
Figure size. The default is FIG_SIZE.
|
|
1721
|
+
|
|
1722
|
+
Returns
|
|
1723
|
+
-------
|
|
1724
|
+
Figure
|
|
1725
|
+
The new Matplotlib figure with the plot.
|
|
1726
|
+
"""
|
|
1727
|
+
kwargs: Dict[str, Any] = {}
|
|
1728
|
+
if layout_seed is not None:
|
|
1729
|
+
kwargs["layout_seed"] = layout_seed
|
|
1730
|
+
|
|
1731
|
+
network_style_template, _, _, _, fplot_network, _, _ = _network_imports()
|
|
1732
|
+
|
|
1733
|
+
return fplot_network(
|
|
1734
|
+
pd_df=self._obj,
|
|
1735
|
+
edge_source_col=edge_source_col,
|
|
1736
|
+
edge_target_col=edge_target_col,
|
|
1737
|
+
edge_weight_col=edge_weight_col,
|
|
1738
|
+
title=title,
|
|
1739
|
+
style=style or network_style_template,
|
|
1740
|
+
figsize=figsize,
|
|
1741
|
+
**kwargs,
|
|
1742
|
+
)
|
|
1743
|
+
|
|
1744
|
+
def fplot_network_node(
|
|
1745
|
+
self,
|
|
1746
|
+
node: Any,
|
|
1747
|
+
edge_source_col: str = "source",
|
|
1748
|
+
edge_target_col: str = "target",
|
|
1749
|
+
edge_weight_col: str = "weight",
|
|
1750
|
+
layout_seed: Optional[int] = None,
|
|
1751
|
+
title: Optional[str] = None,
|
|
1752
|
+
style: Optional[StyleTemplate] = None,
|
|
1753
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1754
|
+
) -> Figure:
|
|
1755
|
+
"""Plot the connected component containing ``node`` on a new figure.
|
|
1756
|
+
|
|
1757
|
+
Parameters
|
|
1758
|
+
----------
|
|
1759
|
+
node : Any
|
|
1760
|
+
Node identifier whose component should be visualized.
|
|
1761
|
+
node_col : str, optional
|
|
1762
|
+
Column for node identifiers. The default is "node".
|
|
1763
|
+
node_weight_col : str, optional
|
|
1764
|
+
Column for node weights. The default is "weight".
|
|
1765
|
+
edge_source_col : str, optional
|
|
1766
|
+
Column for source nodes. The default is "source".
|
|
1767
|
+
edge_target_col : str, optional
|
|
1768
|
+
Column for target nodes. The default is "target".
|
|
1769
|
+
edge_weight_col : str, optional
|
|
1770
|
+
Column for edge weights. The default is "weight".
|
|
1467
1771
|
sort_by : str, optional
|
|
1468
1772
|
Column to sort by.
|
|
1469
1773
|
ascending : bool, optional
|
|
1470
1774
|
Sort order. The default is `False`.
|
|
1471
|
-
|
|
1472
|
-
|
|
1775
|
+
node_df : pd.DataFrame, optional
|
|
1776
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1777
|
+
layout_seed : int, optional
|
|
1778
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1779
|
+
title : str, optional
|
|
1780
|
+
Chart title. Defaults to the formatted node label when ``None``.
|
|
1781
|
+
style : StyleTemplate, optional
|
|
1782
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1473
1783
|
figsize : tuple[float, float], optional
|
|
1474
1784
|
Figure size. The default is FIG_SIZE.
|
|
1475
1785
|
|
|
@@ -1477,30 +1787,38 @@ class DataFrameAccessor:
|
|
|
1477
1787
|
-------
|
|
1478
1788
|
Figure
|
|
1479
1789
|
The new Matplotlib figure with the plot.
|
|
1790
|
+
|
|
1791
|
+
Raises
|
|
1792
|
+
------
|
|
1793
|
+
ValueError
|
|
1794
|
+
If ``node`` is not present in the prepared graph.
|
|
1480
1795
|
"""
|
|
1481
|
-
|
|
1796
|
+
kwargs: Dict[str, Any] = {}
|
|
1797
|
+
if layout_seed is not None:
|
|
1798
|
+
kwargs["layout_seed"] = layout_seed
|
|
1799
|
+
|
|
1800
|
+
network_style_template, _, _, _, _, fplot_network_node, _ = _network_imports()
|
|
1801
|
+
|
|
1802
|
+
return fplot_network_node(
|
|
1482
1803
|
pd_df=self._obj,
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1804
|
+
node=node,
|
|
1805
|
+
edge_source_col=edge_source_col,
|
|
1806
|
+
edge_target_col=edge_target_col,
|
|
1807
|
+
edge_weight_col=edge_weight_col,
|
|
1486
1808
|
title=title,
|
|
1487
|
-
style=style,
|
|
1488
|
-
sort_by=sort_by,
|
|
1489
|
-
ascending=ascending,
|
|
1490
|
-
node_list=node_list,
|
|
1809
|
+
style=style or network_style_template,
|
|
1491
1810
|
figsize=figsize,
|
|
1811
|
+
**kwargs,
|
|
1492
1812
|
)
|
|
1493
1813
|
|
|
1494
1814
|
def fplot_network_components(
|
|
1495
1815
|
self,
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1816
|
+
edge_source_col: str = "source",
|
|
1817
|
+
edge_target_col: str = "target",
|
|
1818
|
+
edge_weight_col: str = "weight",
|
|
1499
1819
|
title: Optional[str] = None,
|
|
1500
|
-
style: StyleTemplate =
|
|
1501
|
-
|
|
1502
|
-
ascending: bool = False,
|
|
1503
|
-
node_list: Optional[List] = None,
|
|
1820
|
+
style: Optional[StyleTemplate] = None,
|
|
1821
|
+
layout_seed: Optional[int] = None,
|
|
1504
1822
|
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1505
1823
|
n_cols: Optional[int] = None,
|
|
1506
1824
|
) -> Figure:
|
|
@@ -1508,22 +1826,28 @@ class DataFrameAccessor:
|
|
|
1508
1826
|
|
|
1509
1827
|
Parameters
|
|
1510
1828
|
----------
|
|
1511
|
-
|
|
1829
|
+
node_col : str, optional
|
|
1830
|
+
Column for node identifiers. The default is "node".
|
|
1831
|
+
node_weight_col : str, optional
|
|
1832
|
+
Column for node weights. The default is "weight".
|
|
1833
|
+
edge_source_col : str, optional
|
|
1512
1834
|
Column for source nodes. The default is "source".
|
|
1513
|
-
|
|
1835
|
+
edge_target_col : str, optional
|
|
1514
1836
|
Column for target nodes. The default is "target".
|
|
1515
|
-
|
|
1837
|
+
edge_weight_col : str, optional
|
|
1516
1838
|
Column for edge weights. The default is "weight".
|
|
1517
|
-
title : str, optional
|
|
1518
|
-
Chart title.
|
|
1519
|
-
style : StyleTemplate, optional
|
|
1520
|
-
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1521
1839
|
sort_by : str, optional
|
|
1522
1840
|
Column to sort by.
|
|
1523
1841
|
ascending : bool, optional
|
|
1524
1842
|
Sort order. The default is `False`.
|
|
1525
|
-
|
|
1526
|
-
|
|
1843
|
+
node_df : pd.DataFrame, optional
|
|
1844
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1845
|
+
title : str, optional
|
|
1846
|
+
Chart title.
|
|
1847
|
+
style : StyleTemplate, optional
|
|
1848
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1849
|
+
layout_seed : int, optional
|
|
1850
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1527
1851
|
figsize : tuple[float, float], optional
|
|
1528
1852
|
Figure size. The default is FIG_SIZE.
|
|
1529
1853
|
n_cols : int, optional
|
|
@@ -1534,18 +1858,24 @@ class DataFrameAccessor:
|
|
|
1534
1858
|
Figure
|
|
1535
1859
|
The new Matplotlib figure with component plots.
|
|
1536
1860
|
"""
|
|
1861
|
+
kwargs: Dict[str, Any] = {}
|
|
1862
|
+
if layout_seed is not None:
|
|
1863
|
+
kwargs["layout_seed"] = layout_seed
|
|
1864
|
+
|
|
1865
|
+
network_style_template, _, _, _, _, _, fplot_network_components = (
|
|
1866
|
+
_network_imports()
|
|
1867
|
+
)
|
|
1868
|
+
|
|
1537
1869
|
return fplot_network_components(
|
|
1538
1870
|
pd_df=self._obj,
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1871
|
+
edge_source_col=edge_source_col,
|
|
1872
|
+
edge_target_col=edge_target_col,
|
|
1873
|
+
edge_weight_col=edge_weight_col,
|
|
1542
1874
|
title=title,
|
|
1543
|
-
style=style,
|
|
1544
|
-
sort_by=sort_by,
|
|
1545
|
-
ascending=ascending,
|
|
1546
|
-
node_list=node_list,
|
|
1875
|
+
style=style or network_style_template,
|
|
1547
1876
|
figsize=figsize,
|
|
1548
1877
|
n_cols=n_cols,
|
|
1878
|
+
**kwargs,
|
|
1549
1879
|
)
|
|
1550
1880
|
|
|
1551
1881
|
def fplot_treemap(
|
|
@@ -1598,7 +1928,7 @@ class DataFrameAccessor:
|
|
|
1598
1928
|
sort_by=sort_by,
|
|
1599
1929
|
max_values=max_values,
|
|
1600
1930
|
ascending=ascending,
|
|
1601
|
-
fig=fig,
|
|
1931
|
+
fig=fig, # type: ignore
|
|
1602
1932
|
)
|
|
1603
1933
|
|
|
1604
1934
|
def fplot_sunburst(
|
|
@@ -1608,10 +1938,6 @@ class DataFrameAccessor:
|
|
|
1608
1938
|
values: str,
|
|
1609
1939
|
style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
|
|
1610
1940
|
title: Optional[str] = None,
|
|
1611
|
-
sort_by: Optional[str] = None,
|
|
1612
|
-
max_values: int = 100,
|
|
1613
|
-
ascending: bool = False,
|
|
1614
|
-
fig: Optional[go.Figure] = None,
|
|
1615
1941
|
) -> go.Figure:
|
|
1616
1942
|
"""Plot a sunburst chart on a new Plotly figure.
|
|
1617
1943
|
|
|
@@ -1635,6 +1961,7 @@ class DataFrameAccessor:
|
|
|
1635
1961
|
Sort order. The default is `False`.
|
|
1636
1962
|
fig : go.Figure, optional
|
|
1637
1963
|
Existing Plotly figure to add to. If None, a new figure is created.
|
|
1964
|
+
|
|
1638
1965
|
Returns
|
|
1639
1966
|
-------
|
|
1640
1967
|
go.Figure
|
|
@@ -1647,10 +1974,6 @@ class DataFrameAccessor:
|
|
|
1647
1974
|
values=values,
|
|
1648
1975
|
title=title,
|
|
1649
1976
|
style=style,
|
|
1650
|
-
sort_by=sort_by,
|
|
1651
|
-
ascending=ascending,
|
|
1652
|
-
max_values=max_values,
|
|
1653
|
-
fig=fig,
|
|
1654
1977
|
)
|
|
1655
1978
|
|
|
1656
1979
|
def fplot_composite_treemap(
|