MatplotLibAPI 3.2.20__py3-none-any.whl → 3.3.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/Bubble.py +9 -6
- MatplotLibAPI/Composite.py +133 -6
- MatplotLibAPI/Network.py +1101 -234
- MatplotLibAPI/StyleTemplate.py +19 -18
- MatplotLibAPI/Table.py +14 -4
- MatplotLibAPI/Timeserie.py +3 -2
- MatplotLibAPI/Wordcloud.py +61 -47
- MatplotLibAPI/__init__.py +10 -5
- MatplotLibAPI/accessor.py +333 -106
- {matplotlibapi-3.2.20.dist-info → matplotlibapi-3.3.0.dist-info}/METADATA +1 -1
- matplotlibapi-3.3.0.dist-info/RECORD +26 -0
- matplotlibapi-3.2.20.dist-info/RECORD +0 -26
- {matplotlibapi-3.2.20.dist-info → matplotlibapi-3.3.0.dist-info}/WHEEL +0 -0
- {matplotlibapi-3.2.20.dist-info → matplotlibapi-3.3.0.dist-info}/licenses/LICENSE +0 -0
MatplotLibAPI/accessor.py
CHANGED
|
@@ -25,13 +25,16 @@ from .Histogram import aplot_histogram_kde, fplot_histogram_kde
|
|
|
25
25
|
from .Network import (
|
|
26
26
|
NETWORK_STYLE_TEMPLATE,
|
|
27
27
|
aplot_network,
|
|
28
|
+
aplot_network_node,
|
|
28
29
|
aplot_network_components,
|
|
30
|
+
fplot_network_node,
|
|
29
31
|
fplot_network_components,
|
|
30
32
|
fplot_network,
|
|
31
33
|
)
|
|
32
34
|
from .Pie import aplot_pie_donut, fplot_pie_donut
|
|
33
35
|
from .Sankey import SANKEY_STYLE_TEMPLATE, fplot_sankey
|
|
34
36
|
from .StyleTemplate import (
|
|
37
|
+
FIG_SIZE,
|
|
35
38
|
AREA_STYLE_TEMPLATE,
|
|
36
39
|
DISTRIBUTION_STYLE_TEMPLATE,
|
|
37
40
|
PIE_STYLE_TEMPLATE,
|
|
@@ -109,10 +112,14 @@ class DataFrameAccessor:
|
|
|
109
112
|
Plot a word cloud on a new figure.
|
|
110
113
|
aplot_network
|
|
111
114
|
Plot a network graph on a Matplotlib axes.
|
|
115
|
+
aplot_network_node
|
|
116
|
+
Plot the connected component for a specific node on a Matplotlib axes.
|
|
112
117
|
aplot_network_components
|
|
113
118
|
Plot connected components of a network graph on multiple axes.
|
|
114
119
|
fplot_network
|
|
115
120
|
Plot a network graph on a new figure.
|
|
121
|
+
fplot_network_node
|
|
122
|
+
Plot the connected component for a specific node on a new figure.
|
|
116
123
|
fplot_network_components
|
|
117
124
|
Plot connected components of a network graph on a new figure.
|
|
118
125
|
fplot_treemap
|
|
@@ -210,7 +217,7 @@ class DataFrameAccessor:
|
|
|
210
217
|
ascending: bool = False,
|
|
211
218
|
hline: bool = False,
|
|
212
219
|
vline: bool = False,
|
|
213
|
-
figsize: Tuple[float, float] =
|
|
220
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
214
221
|
save_path: Optional[str] = None,
|
|
215
222
|
savefig_kwargs: Optional[Dict[str, Any]] = None,
|
|
216
223
|
) -> Figure:
|
|
@@ -243,7 +250,7 @@ class DataFrameAccessor:
|
|
|
243
250
|
vline : bool, optional
|
|
244
251
|
If True, draw a vertical line at the mean of x-values. The default is `False`.
|
|
245
252
|
figsize : tuple[float, float], optional
|
|
246
|
-
Figure size. The default is
|
|
253
|
+
Figure size. The default is FIG_SIZE.
|
|
247
254
|
|
|
248
255
|
Returns
|
|
249
256
|
-------
|
|
@@ -386,7 +393,7 @@ class DataFrameAccessor:
|
|
|
386
393
|
stacked: bool = False,
|
|
387
394
|
title: Optional[str] = None,
|
|
388
395
|
style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
|
|
389
|
-
figsize: Tuple[float, float] =
|
|
396
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
390
397
|
) -> Figure:
|
|
391
398
|
"""Plot bar or stacked bar charts on a new figure.
|
|
392
399
|
|
|
@@ -405,7 +412,7 @@ class DataFrameAccessor:
|
|
|
405
412
|
style : StyleTemplate, optional
|
|
406
413
|
Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
|
|
407
414
|
figsize : tuple[float, float], optional
|
|
408
|
-
Figure size. The default is
|
|
415
|
+
Figure size. The default is FIG_SIZE.
|
|
409
416
|
|
|
410
417
|
Returns
|
|
411
418
|
-------
|
|
@@ -471,7 +478,7 @@ class DataFrameAccessor:
|
|
|
471
478
|
kde: bool = True,
|
|
472
479
|
title: Optional[str] = None,
|
|
473
480
|
style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
|
|
474
|
-
figsize: Tuple[float, float] =
|
|
481
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
475
482
|
) -> Figure:
|
|
476
483
|
"""Plot a histogram with an optional KDE on a new figure.
|
|
477
484
|
|
|
@@ -488,7 +495,7 @@ class DataFrameAccessor:
|
|
|
488
495
|
style : StyleTemplate, optional
|
|
489
496
|
Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
|
|
490
497
|
figsize : tuple[float, float], optional
|
|
491
|
-
Figure size. The default is
|
|
498
|
+
Figure size. The default is FIG_SIZE.
|
|
492
499
|
|
|
493
500
|
Returns
|
|
494
501
|
-------
|
|
@@ -553,7 +560,7 @@ class DataFrameAccessor:
|
|
|
553
560
|
violin: bool = False,
|
|
554
561
|
title: Optional[str] = None,
|
|
555
562
|
style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
|
|
556
|
-
figsize: Tuple[float, float] =
|
|
563
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
557
564
|
) -> Figure:
|
|
558
565
|
"""Plot box or violin charts on a new figure.
|
|
559
566
|
|
|
@@ -570,7 +577,7 @@ class DataFrameAccessor:
|
|
|
570
577
|
style : StyleTemplate, optional
|
|
571
578
|
Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
|
|
572
579
|
figsize : tuple[float, float], optional
|
|
573
|
-
Figure size. The default is
|
|
580
|
+
Figure size. The default is FIG_SIZE.
|
|
574
581
|
|
|
575
582
|
Returns
|
|
576
583
|
-------
|
|
@@ -635,7 +642,7 @@ class DataFrameAccessor:
|
|
|
635
642
|
value: str,
|
|
636
643
|
title: Optional[str] = None,
|
|
637
644
|
style: StyleTemplate = HEATMAP_STYLE_TEMPLATE,
|
|
638
|
-
figsize: Tuple[float, float] =
|
|
645
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
639
646
|
) -> Figure:
|
|
640
647
|
"""Plot a heatmap on a new figure.
|
|
641
648
|
|
|
@@ -652,7 +659,7 @@ class DataFrameAccessor:
|
|
|
652
659
|
style : StyleTemplate, optional
|
|
653
660
|
Styling template. The default is ``HEATMAP_STYLE_TEMPLATE``.
|
|
654
661
|
figsize : tuple[float, float], optional
|
|
655
|
-
Figure size. The default is
|
|
662
|
+
Figure size. The default is FIG_SIZE.
|
|
656
663
|
|
|
657
664
|
Returns
|
|
658
665
|
-------
|
|
@@ -712,7 +719,7 @@ class DataFrameAccessor:
|
|
|
712
719
|
method: CorrelationMethod = "pearson",
|
|
713
720
|
title: Optional[str] = None,
|
|
714
721
|
style: StyleTemplate = HEATMAP_STYLE_TEMPLATE,
|
|
715
|
-
figsize: Tuple[float, float] =
|
|
722
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
716
723
|
) -> Figure:
|
|
717
724
|
"""Plot a correlation matrix heatmap on a new figure.
|
|
718
725
|
|
|
@@ -727,7 +734,7 @@ class DataFrameAccessor:
|
|
|
727
734
|
style : StyleTemplate, optional
|
|
728
735
|
Styling template. The default is ``HEATMAP_STYLE_TEMPLATE``.
|
|
729
736
|
figsize : tuple[float, float], optional
|
|
730
|
-
Figure size. The default is
|
|
737
|
+
Figure size. The default is FIG_SIZE.
|
|
731
738
|
|
|
732
739
|
Returns
|
|
733
740
|
-------
|
|
@@ -796,7 +803,7 @@ class DataFrameAccessor:
|
|
|
796
803
|
stacked: bool = True,
|
|
797
804
|
title: Optional[str] = None,
|
|
798
805
|
style: StyleTemplate = AREA_STYLE_TEMPLATE,
|
|
799
|
-
figsize: Tuple[float, float] =
|
|
806
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
800
807
|
) -> Figure:
|
|
801
808
|
"""Plot an area chart on a new figure.
|
|
802
809
|
|
|
@@ -815,7 +822,7 @@ class DataFrameAccessor:
|
|
|
815
822
|
style : StyleTemplate, optional
|
|
816
823
|
Styling template. The default is ``AREA_STYLE_TEMPLATE``.
|
|
817
824
|
figsize : tuple[float, float], optional
|
|
818
|
-
Figure size. The default is
|
|
825
|
+
Figure size. The default is FIG_SIZE.
|
|
819
826
|
|
|
820
827
|
Returns
|
|
821
828
|
-------
|
|
@@ -881,7 +888,7 @@ class DataFrameAccessor:
|
|
|
881
888
|
donut: bool = False,
|
|
882
889
|
title: Optional[str] = None,
|
|
883
890
|
style: StyleTemplate = PIE_STYLE_TEMPLATE,
|
|
884
|
-
figsize: Tuple[float, float] =
|
|
891
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
885
892
|
) -> Figure:
|
|
886
893
|
"""Plot pie or donut charts on a new figure.
|
|
887
894
|
|
|
@@ -898,7 +905,7 @@ class DataFrameAccessor:
|
|
|
898
905
|
style : StyleTemplate, optional
|
|
899
906
|
Styling template. The default is ``PIE_STYLE_TEMPLATE``.
|
|
900
907
|
figsize : tuple[float, float], optional
|
|
901
|
-
Figure size. The default is
|
|
908
|
+
Figure size. The default is FIG_SIZE.
|
|
902
909
|
|
|
903
910
|
Returns
|
|
904
911
|
-------
|
|
@@ -963,7 +970,7 @@ class DataFrameAccessor:
|
|
|
963
970
|
rows: int = 10,
|
|
964
971
|
title: Optional[str] = None,
|
|
965
972
|
style: StyleTemplate = PIE_STYLE_TEMPLATE,
|
|
966
|
-
figsize: Tuple[float, float] =
|
|
973
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
967
974
|
) -> Figure:
|
|
968
975
|
"""Plot waffle charts on a new figure.
|
|
969
976
|
|
|
@@ -980,7 +987,7 @@ class DataFrameAccessor:
|
|
|
980
987
|
style : StyleTemplate, optional
|
|
981
988
|
Styling template. The default is ``PIE_STYLE_TEMPLATE``.
|
|
982
989
|
figsize : tuple[float, float], optional
|
|
983
|
-
Figure size. The default is
|
|
990
|
+
Figure size. The default is FIG_SIZE.
|
|
984
991
|
|
|
985
992
|
Returns
|
|
986
993
|
-------
|
|
@@ -1087,7 +1094,7 @@ class DataFrameAccessor:
|
|
|
1087
1094
|
max_values: int = 20,
|
|
1088
1095
|
sort_by: Optional[str] = None,
|
|
1089
1096
|
ascending: bool = False,
|
|
1090
|
-
figsize: Tuple[float, float] =
|
|
1097
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1091
1098
|
) -> Figure:
|
|
1092
1099
|
"""Plot a table of the DataFrame's data on a new figure.
|
|
1093
1100
|
|
|
@@ -1106,7 +1113,7 @@ class DataFrameAccessor:
|
|
|
1106
1113
|
ascending : bool, optional
|
|
1107
1114
|
Sort order. The default is `False`.
|
|
1108
1115
|
figsize : tuple[float, float], optional
|
|
1109
|
-
Figure size. The default is
|
|
1116
|
+
Figure size. The default is FIG_SIZE.
|
|
1110
1117
|
|
|
1111
1118
|
Returns
|
|
1112
1119
|
-------
|
|
@@ -1192,7 +1199,7 @@ class DataFrameAccessor:
|
|
|
1192
1199
|
sort_by: Optional[str] = None,
|
|
1193
1200
|
ascending: bool = False,
|
|
1194
1201
|
std: bool = False,
|
|
1195
|
-
figsize: Tuple[float, float] =
|
|
1202
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1196
1203
|
) -> Figure:
|
|
1197
1204
|
"""Plot a time series on a new figure.
|
|
1198
1205
|
|
|
@@ -1217,7 +1224,7 @@ class DataFrameAccessor:
|
|
|
1217
1224
|
std : bool, optional
|
|
1218
1225
|
If True, plot the standard deviation. The default is `False`.
|
|
1219
1226
|
figsize : tuple[float, float], optional
|
|
1220
|
-
Figure size. The default is
|
|
1227
|
+
Figure size. The default is FIG_SIZE.
|
|
1221
1228
|
|
|
1222
1229
|
Returns
|
|
1223
1230
|
-------
|
|
@@ -1296,7 +1303,7 @@ class DataFrameAccessor:
|
|
|
1296
1303
|
max_words: int = 50,
|
|
1297
1304
|
stopwords: Optional[List[str]] = None,
|
|
1298
1305
|
random_state: Optional[int] = None,
|
|
1299
|
-
figsize: Tuple[float, float] =
|
|
1306
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1300
1307
|
) -> Figure:
|
|
1301
1308
|
"""Plot a word cloud on a new figure.
|
|
1302
1309
|
|
|
@@ -1317,7 +1324,7 @@ class DataFrameAccessor:
|
|
|
1317
1324
|
random_state : int, optional
|
|
1318
1325
|
Seed for word placement. The default is ``None``.
|
|
1319
1326
|
figsize : tuple[float, float], optional
|
|
1320
|
-
Figure size. The default is
|
|
1327
|
+
Figure size. The default is FIG_SIZE.
|
|
1321
1328
|
|
|
1322
1329
|
Returns
|
|
1323
1330
|
-------
|
|
@@ -1338,36 +1345,117 @@ class DataFrameAccessor:
|
|
|
1338
1345
|
|
|
1339
1346
|
def aplot_network(
|
|
1340
1347
|
self,
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1348
|
+
node_col: str = "node",
|
|
1349
|
+
node_weight_col: str = "weight",
|
|
1350
|
+
edge_source_col: str = "source",
|
|
1351
|
+
edge_target_col: str = "target",
|
|
1352
|
+
edge_weight_col: str = "weight",
|
|
1346
1353
|
sort_by: Optional[str] = None,
|
|
1347
1354
|
ascending: bool = False,
|
|
1348
|
-
|
|
1355
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1356
|
+
title: Optional[str] = None,
|
|
1357
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1358
|
+
layout_seed: Optional[int] = None,
|
|
1349
1359
|
ax: Optional[Axes] = None,
|
|
1350
1360
|
) -> Axes:
|
|
1351
1361
|
"""Plot a network graph on a Matplotlib axes.
|
|
1352
1362
|
|
|
1353
1363
|
Parameters
|
|
1354
1364
|
----------
|
|
1355
|
-
|
|
1365
|
+
node_col : str, optional
|
|
1366
|
+
Column for node identifiers. The default is "node".
|
|
1367
|
+
node_weight_col : str, optional
|
|
1368
|
+
Column for node weights. The default is "weight".
|
|
1369
|
+
edge_source_col : str, optional
|
|
1356
1370
|
Column for source nodes. The default is "source".
|
|
1357
|
-
|
|
1371
|
+
edge_target_col : str, optional
|
|
1358
1372
|
Column for target nodes. The default is "target".
|
|
1359
|
-
|
|
1373
|
+
edge_weight_col : str, optional
|
|
1360
1374
|
Column for edge weights. The default is "weight".
|
|
1375
|
+
sort_by : str, optional
|
|
1376
|
+
Column to sort by.
|
|
1377
|
+
ascending : bool, optional
|
|
1378
|
+
Sort order. The default is `False`.
|
|
1379
|
+
node_df : pd.DataFrame, optional
|
|
1380
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1361
1381
|
title : str, optional
|
|
1362
1382
|
Chart title.
|
|
1363
1383
|
style : StyleTemplate, optional
|
|
1364
1384
|
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1385
|
+
layout_seed : int, optional
|
|
1386
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1387
|
+
ax : Axes, optional
|
|
1388
|
+
Matplotlib axes to plot on. If None, uses the current axes.
|
|
1389
|
+
|
|
1390
|
+
Returns
|
|
1391
|
+
-------
|
|
1392
|
+
Axes
|
|
1393
|
+
The Matplotlib axes object with the plot.
|
|
1394
|
+
"""
|
|
1395
|
+
kwargs: Dict[str, Any] = {}
|
|
1396
|
+
if layout_seed is not None:
|
|
1397
|
+
kwargs["layout_seed"] = layout_seed
|
|
1398
|
+
|
|
1399
|
+
return aplot_network(
|
|
1400
|
+
pd_df=self._obj,
|
|
1401
|
+
node_col=node_col,
|
|
1402
|
+
node_weight_col=node_weight_col,
|
|
1403
|
+
edge_source_col=edge_source_col,
|
|
1404
|
+
edge_target_col=edge_target_col,
|
|
1405
|
+
edge_weight_col=edge_weight_col,
|
|
1406
|
+
sort_by=sort_by,
|
|
1407
|
+
ascending=ascending,
|
|
1408
|
+
node_df=node_df,
|
|
1409
|
+
title=title,
|
|
1410
|
+
style=style,
|
|
1411
|
+
ax=ax,
|
|
1412
|
+
**kwargs,
|
|
1413
|
+
)
|
|
1414
|
+
|
|
1415
|
+
def aplot_network_node(
|
|
1416
|
+
self,
|
|
1417
|
+
node: Any,
|
|
1418
|
+
node_col: str = "node",
|
|
1419
|
+
node_weight_col: str = "weight",
|
|
1420
|
+
edge_source_col: str = "source",
|
|
1421
|
+
edge_target_col: str = "target",
|
|
1422
|
+
edge_weight_col: str = "weight",
|
|
1423
|
+
sort_by: Optional[str] = None,
|
|
1424
|
+
ascending: bool = False,
|
|
1425
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1426
|
+
layout_seed: Optional[int] = None,
|
|
1427
|
+
title: Optional[str] = None,
|
|
1428
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1429
|
+
ax: Optional[Axes] = None,
|
|
1430
|
+
) -> Axes:
|
|
1431
|
+
"""Plot the connected component containing ``node``.
|
|
1432
|
+
|
|
1433
|
+
Parameters
|
|
1434
|
+
----------
|
|
1435
|
+
node : Any
|
|
1436
|
+
Node identifier whose component should be visualized.
|
|
1437
|
+
node_col : str, optional
|
|
1438
|
+
Column for node identifiers. The default is "node".
|
|
1439
|
+
node_weight_col : str, optional
|
|
1440
|
+
Column for node weights. The default is "weight".
|
|
1441
|
+
edge_source_col : str, optional
|
|
1442
|
+
Column for source nodes. The default is "source".
|
|
1443
|
+
edge_target_col : str, optional
|
|
1444
|
+
Column for target nodes. The default is "target".
|
|
1445
|
+
edge_weight_col : str, optional
|
|
1446
|
+
Column for edge weights. The default is "weight".
|
|
1365
1447
|
sort_by : str, optional
|
|
1366
1448
|
Column to sort by.
|
|
1367
1449
|
ascending : bool, optional
|
|
1368
1450
|
Sort order. The default is `False`.
|
|
1369
|
-
|
|
1370
|
-
|
|
1451
|
+
node_df : pd.DataFrame, optional
|
|
1452
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1453
|
+
layout_seed : int, optional
|
|
1454
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1455
|
+
title : str, optional
|
|
1456
|
+
Chart title. Defaults to the formatted node label when ``None``.
|
|
1457
|
+
style : StyleTemplate, optional
|
|
1458
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1371
1459
|
ax : Axes, optional
|
|
1372
1460
|
Matplotlib axes to plot on. If None, uses the current axes.
|
|
1373
1461
|
|
|
@@ -1375,156 +1463,288 @@ class DataFrameAccessor:
|
|
|
1375
1463
|
-------
|
|
1376
1464
|
Axes
|
|
1377
1465
|
The Matplotlib axes object with the plot.
|
|
1466
|
+
|
|
1467
|
+
Raises
|
|
1468
|
+
------
|
|
1469
|
+
ValueError
|
|
1470
|
+
If ``node`` is not present in the prepared graph.
|
|
1378
1471
|
"""
|
|
1379
|
-
|
|
1472
|
+
kwargs: Dict[str, Any] = {}
|
|
1473
|
+
if layout_seed is not None:
|
|
1474
|
+
kwargs["layout_seed"] = layout_seed
|
|
1475
|
+
|
|
1476
|
+
return aplot_network_node(
|
|
1380
1477
|
pd_df=self._obj,
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1478
|
+
node=node,
|
|
1479
|
+
node_col=node_col,
|
|
1480
|
+
node_weight_col=node_weight_col,
|
|
1481
|
+
edge_source_col=edge_source_col,
|
|
1482
|
+
edge_target_col=edge_target_col,
|
|
1483
|
+
edge_weight_col=edge_weight_col,
|
|
1386
1484
|
sort_by=sort_by,
|
|
1387
1485
|
ascending=ascending,
|
|
1388
|
-
|
|
1486
|
+
node_df=node_df,
|
|
1487
|
+
title=title,
|
|
1488
|
+
style=style,
|
|
1389
1489
|
ax=ax,
|
|
1490
|
+
**kwargs,
|
|
1390
1491
|
)
|
|
1391
1492
|
|
|
1392
1493
|
def aplot_network_components(
|
|
1393
1494
|
self,
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1495
|
+
node_col: str = "node",
|
|
1496
|
+
node_weight_col: str = "weight",
|
|
1497
|
+
edge_source_col: str = "source",
|
|
1498
|
+
edge_target_col: str = "target",
|
|
1499
|
+
edge_weight_col: str = "weight",
|
|
1399
1500
|
sort_by: Optional[str] = None,
|
|
1400
1501
|
ascending: bool = False,
|
|
1401
|
-
|
|
1502
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1503
|
+
title: Optional[str] = None,
|
|
1504
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1505
|
+
layout_seed: Optional[int] = None,
|
|
1402
1506
|
axes: Optional[np.ndarray] = None,
|
|
1403
1507
|
) -> None:
|
|
1404
1508
|
"""Plot connected components of a network graph on multiple axes.
|
|
1405
1509
|
|
|
1406
1510
|
Parameters
|
|
1407
1511
|
----------
|
|
1408
|
-
|
|
1512
|
+
node_col : str, optional
|
|
1513
|
+
Column for node identifiers. The default is "node".
|
|
1514
|
+
node_weight_col : str, optional
|
|
1515
|
+
Column for node weights. The default is "weight".
|
|
1516
|
+
edge_source_col : str, optional
|
|
1409
1517
|
Column for source nodes. The default is "source".
|
|
1410
|
-
|
|
1518
|
+
edge_target_col : str, optional
|
|
1411
1519
|
Column for target nodes. The default is "target".
|
|
1412
|
-
|
|
1520
|
+
edge_weight_col : str, optional
|
|
1413
1521
|
Column for edge weights. The default is "weight".
|
|
1414
|
-
title : str, optional
|
|
1415
|
-
Chart title.
|
|
1416
|
-
style : StyleTemplate, optional
|
|
1417
|
-
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1418
1522
|
sort_by : str, optional
|
|
1419
1523
|
Column to sort by.
|
|
1420
1524
|
ascending : bool, optional
|
|
1421
1525
|
Sort order. The default is `False`.
|
|
1422
|
-
|
|
1423
|
-
|
|
1526
|
+
node_df : pd.DataFrame, optional
|
|
1527
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1528
|
+
title : str, optional
|
|
1529
|
+
Chart title.
|
|
1530
|
+
style : StyleTemplate, optional
|
|
1531
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1532
|
+
layout_seed : int, optional
|
|
1533
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1424
1534
|
axes : np.ndarray, optional
|
|
1425
1535
|
Numpy array of Matplotlib axes to plot on. If None, new axes are created.
|
|
1426
1536
|
"""
|
|
1537
|
+
kwargs: Dict[str, Any] = {}
|
|
1538
|
+
if layout_seed is not None:
|
|
1539
|
+
kwargs["layout_seed"] = layout_seed
|
|
1540
|
+
|
|
1427
1541
|
aplot_network_components(
|
|
1428
1542
|
pd_df=self._obj,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1543
|
+
node_col=node_col,
|
|
1544
|
+
node_weight_col=node_weight_col,
|
|
1545
|
+
edge_source_col=edge_source_col,
|
|
1546
|
+
edge_target_col=edge_target_col,
|
|
1547
|
+
edge_weight_col=edge_weight_col,
|
|
1434
1548
|
sort_by=sort_by,
|
|
1435
1549
|
ascending=ascending,
|
|
1436
|
-
|
|
1550
|
+
node_df=node_df,
|
|
1551
|
+
title=title,
|
|
1552
|
+
style=style,
|
|
1437
1553
|
axes=axes,
|
|
1554
|
+
**kwargs,
|
|
1438
1555
|
)
|
|
1439
1556
|
|
|
1440
1557
|
def fplot_network(
|
|
1441
1558
|
self,
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1559
|
+
node_col: str = "node",
|
|
1560
|
+
node_weight_col: str = "weight",
|
|
1561
|
+
edge_source_col: str = "source",
|
|
1562
|
+
edge_target_col: str = "target",
|
|
1563
|
+
edge_weight_col: str = "weight",
|
|
1447
1564
|
sort_by: Optional[str] = None,
|
|
1448
1565
|
ascending: bool = False,
|
|
1449
|
-
|
|
1450
|
-
|
|
1566
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1567
|
+
title: Optional[str] = None,
|
|
1568
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1569
|
+
layout_seed: Optional[int] = None,
|
|
1570
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1451
1571
|
) -> Figure:
|
|
1452
1572
|
"""Plot a network graph on a new figure.
|
|
1453
1573
|
|
|
1454
1574
|
Parameters
|
|
1455
1575
|
----------
|
|
1456
|
-
|
|
1576
|
+
node_col : str, optional
|
|
1577
|
+
Column for node identifiers. The default is "node".
|
|
1578
|
+
node_weight_col : str, optional
|
|
1579
|
+
Column for node weights. The default is "weight".
|
|
1580
|
+
edge_source_col : str, optional
|
|
1457
1581
|
Column for source nodes. The default is "source".
|
|
1458
|
-
|
|
1582
|
+
edge_target_col : str, optional
|
|
1459
1583
|
Column for target nodes. The default is "target".
|
|
1460
|
-
|
|
1584
|
+
edge_weight_col : str, optional
|
|
1461
1585
|
Column for edge weights. The default is "weight".
|
|
1586
|
+
sort_by : str, optional
|
|
1587
|
+
Column to sort by.
|
|
1588
|
+
ascending : bool, optional
|
|
1589
|
+
Sort order. The default is `False`.
|
|
1590
|
+
node_df : pd.DataFrame, optional
|
|
1591
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1462
1592
|
title : str, optional
|
|
1463
1593
|
Chart title.
|
|
1464
1594
|
style : StyleTemplate, optional
|
|
1465
1595
|
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1596
|
+
layout_seed : int, optional
|
|
1597
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1598
|
+
figsize : tuple[float, float], optional
|
|
1599
|
+
Figure size. The default is FIG_SIZE.
|
|
1600
|
+
|
|
1601
|
+
Returns
|
|
1602
|
+
-------
|
|
1603
|
+
Figure
|
|
1604
|
+
The new Matplotlib figure with the plot.
|
|
1605
|
+
"""
|
|
1606
|
+
kwargs: Dict[str, Any] = {}
|
|
1607
|
+
if layout_seed is not None:
|
|
1608
|
+
kwargs["layout_seed"] = layout_seed
|
|
1609
|
+
|
|
1610
|
+
return fplot_network(
|
|
1611
|
+
pd_df=self._obj,
|
|
1612
|
+
node_col=node_col,
|
|
1613
|
+
node_weight_col=node_weight_col,
|
|
1614
|
+
edge_source_col=edge_source_col,
|
|
1615
|
+
edge_target_col=edge_target_col,
|
|
1616
|
+
edge_weight_col=edge_weight_col,
|
|
1617
|
+
sort_by=sort_by,
|
|
1618
|
+
ascending=ascending,
|
|
1619
|
+
node_df=node_df,
|
|
1620
|
+
title=title,
|
|
1621
|
+
style=style,
|
|
1622
|
+
figsize=figsize,
|
|
1623
|
+
**kwargs,
|
|
1624
|
+
)
|
|
1625
|
+
|
|
1626
|
+
def fplot_network_node(
|
|
1627
|
+
self,
|
|
1628
|
+
node: Any,
|
|
1629
|
+
node_col: str = "node",
|
|
1630
|
+
node_weight_col: str = "weight",
|
|
1631
|
+
edge_source_col: str = "source",
|
|
1632
|
+
edge_target_col: str = "target",
|
|
1633
|
+
edge_weight_col: str = "weight",
|
|
1634
|
+
sort_by: Optional[str] = None,
|
|
1635
|
+
ascending: bool = False,
|
|
1636
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1637
|
+
layout_seed: Optional[int] = None,
|
|
1638
|
+
title: Optional[str] = None,
|
|
1639
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1640
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1641
|
+
) -> Figure:
|
|
1642
|
+
"""Plot the connected component containing ``node`` on a new figure.
|
|
1643
|
+
|
|
1644
|
+
Parameters
|
|
1645
|
+
----------
|
|
1646
|
+
node : Any
|
|
1647
|
+
Node identifier whose component should be visualized.
|
|
1648
|
+
node_col : str, optional
|
|
1649
|
+
Column for node identifiers. The default is "node".
|
|
1650
|
+
node_weight_col : str, optional
|
|
1651
|
+
Column for node weights. The default is "weight".
|
|
1652
|
+
edge_source_col : str, optional
|
|
1653
|
+
Column for source nodes. The default is "source".
|
|
1654
|
+
edge_target_col : str, optional
|
|
1655
|
+
Column for target nodes. The default is "target".
|
|
1656
|
+
edge_weight_col : str, optional
|
|
1657
|
+
Column for edge weights. The default is "weight".
|
|
1466
1658
|
sort_by : str, optional
|
|
1467
1659
|
Column to sort by.
|
|
1468
1660
|
ascending : bool, optional
|
|
1469
1661
|
Sort order. The default is `False`.
|
|
1470
|
-
|
|
1471
|
-
|
|
1662
|
+
node_df : pd.DataFrame, optional
|
|
1663
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1664
|
+
layout_seed : int, optional
|
|
1665
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1666
|
+
title : str, optional
|
|
1667
|
+
Chart title. Defaults to the formatted node label when ``None``.
|
|
1668
|
+
style : StyleTemplate, optional
|
|
1669
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1472
1670
|
figsize : tuple[float, float], optional
|
|
1473
|
-
Figure size. The default is
|
|
1671
|
+
Figure size. The default is FIG_SIZE.
|
|
1474
1672
|
|
|
1475
1673
|
Returns
|
|
1476
1674
|
-------
|
|
1477
1675
|
Figure
|
|
1478
1676
|
The new Matplotlib figure with the plot.
|
|
1677
|
+
|
|
1678
|
+
Raises
|
|
1679
|
+
------
|
|
1680
|
+
ValueError
|
|
1681
|
+
If ``node`` is not present in the prepared graph.
|
|
1479
1682
|
"""
|
|
1480
|
-
|
|
1683
|
+
kwargs: Dict[str, Any] = {}
|
|
1684
|
+
if layout_seed is not None:
|
|
1685
|
+
kwargs["layout_seed"] = layout_seed
|
|
1686
|
+
|
|
1687
|
+
return fplot_network_node(
|
|
1481
1688
|
pd_df=self._obj,
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1689
|
+
node=node,
|
|
1690
|
+
node_col=node_col,
|
|
1691
|
+
node_weight_col=node_weight_col,
|
|
1692
|
+
edge_source_col=edge_source_col,
|
|
1693
|
+
edge_target_col=edge_target_col,
|
|
1694
|
+
edge_weight_col=edge_weight_col,
|
|
1487
1695
|
sort_by=sort_by,
|
|
1488
1696
|
ascending=ascending,
|
|
1489
|
-
|
|
1697
|
+
node_df=node_df,
|
|
1698
|
+
title=title,
|
|
1699
|
+
style=style,
|
|
1490
1700
|
figsize=figsize,
|
|
1701
|
+
**kwargs,
|
|
1491
1702
|
)
|
|
1492
1703
|
|
|
1493
1704
|
def fplot_network_components(
|
|
1494
1705
|
self,
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1706
|
+
node_col: str = "node",
|
|
1707
|
+
node_weight_col: str = "weight",
|
|
1708
|
+
edge_source_col: str = "source",
|
|
1709
|
+
edge_target_col: str = "target",
|
|
1710
|
+
edge_weight_col: str = "weight",
|
|
1500
1711
|
sort_by: Optional[str] = None,
|
|
1501
1712
|
ascending: bool = False,
|
|
1502
|
-
|
|
1503
|
-
|
|
1713
|
+
node_df: Optional[pd.DataFrame] = None,
|
|
1714
|
+
title: Optional[str] = None,
|
|
1715
|
+
style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
|
|
1716
|
+
layout_seed: Optional[int] = None,
|
|
1717
|
+
figsize: Tuple[float, float] = FIG_SIZE,
|
|
1504
1718
|
n_cols: Optional[int] = None,
|
|
1505
1719
|
) -> Figure:
|
|
1506
1720
|
"""Plot network components on a new figure.
|
|
1507
1721
|
|
|
1508
1722
|
Parameters
|
|
1509
1723
|
----------
|
|
1510
|
-
|
|
1724
|
+
node_col : str, optional
|
|
1725
|
+
Column for node identifiers. The default is "node".
|
|
1726
|
+
node_weight_col : str, optional
|
|
1727
|
+
Column for node weights. The default is "weight".
|
|
1728
|
+
edge_source_col : str, optional
|
|
1511
1729
|
Column for source nodes. The default is "source".
|
|
1512
|
-
|
|
1730
|
+
edge_target_col : str, optional
|
|
1513
1731
|
Column for target nodes. The default is "target".
|
|
1514
|
-
|
|
1732
|
+
edge_weight_col : str, optional
|
|
1515
1733
|
Column for edge weights. The default is "weight".
|
|
1516
|
-
title : str, optional
|
|
1517
|
-
Chart title.
|
|
1518
|
-
style : StyleTemplate, optional
|
|
1519
|
-
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1520
1734
|
sort_by : str, optional
|
|
1521
1735
|
Column to sort by.
|
|
1522
1736
|
ascending : bool, optional
|
|
1523
1737
|
Sort order. The default is `False`.
|
|
1524
|
-
|
|
1525
|
-
|
|
1738
|
+
node_df : pd.DataFrame, optional
|
|
1739
|
+
DataFrame containing ``node`` and ``weight`` columns for weighting.
|
|
1740
|
+
title : str, optional
|
|
1741
|
+
Chart title.
|
|
1742
|
+
style : StyleTemplate, optional
|
|
1743
|
+
Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
|
|
1744
|
+
layout_seed : int, optional
|
|
1745
|
+
Seed forwarded to the spring layout. The default is ``_DEFAULT["SPRING_LAYOUT_SEED"]``.
|
|
1526
1746
|
figsize : tuple[float, float], optional
|
|
1527
|
-
Figure size. The default is
|
|
1747
|
+
Figure size. The default is FIG_SIZE.
|
|
1528
1748
|
n_cols : int, optional
|
|
1529
1749
|
Number of columns for arranging component subplots.
|
|
1530
1750
|
|
|
@@ -1533,18 +1753,25 @@ class DataFrameAccessor:
|
|
|
1533
1753
|
Figure
|
|
1534
1754
|
The new Matplotlib figure with component plots.
|
|
1535
1755
|
"""
|
|
1756
|
+
kwargs: Dict[str, Any] = {}
|
|
1757
|
+
if layout_seed is not None:
|
|
1758
|
+
kwargs["layout_seed"] = layout_seed
|
|
1759
|
+
|
|
1536
1760
|
return fplot_network_components(
|
|
1537
1761
|
pd_df=self._obj,
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1762
|
+
node_col=node_col,
|
|
1763
|
+
node_weight_col=node_weight_col,
|
|
1764
|
+
edge_source_col=edge_source_col,
|
|
1765
|
+
edge_target_col=edge_target_col,
|
|
1766
|
+
edge_weight_col=edge_weight_col,
|
|
1543
1767
|
sort_by=sort_by,
|
|
1544
1768
|
ascending=ascending,
|
|
1545
|
-
|
|
1769
|
+
node_df=node_df,
|
|
1770
|
+
title=title,
|
|
1771
|
+
style=style,
|
|
1546
1772
|
figsize=figsize,
|
|
1547
1773
|
n_cols=n_cols,
|
|
1774
|
+
**kwargs,
|
|
1548
1775
|
)
|
|
1549
1776
|
|
|
1550
1777
|
def fplot_treemap(
|