MatplotLibAPI 4.0.0__py3-none-any.whl → 4.0.2__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/accessor.py CHANGED
@@ -27,12 +27,6 @@ if TYPE_CHECKING:
27
27
  import plotly.graph_objects as go
28
28
 
29
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
30
  def _heatmap_imports() -> tuple[StyleTemplate, Any, Any, Any, Any]:
37
31
  from .heatmap import (
38
32
  HEATMAP_STYLE_TEMPLATE,
@@ -85,42 +79,6 @@ def _sankey_imports() -> tuple[StyleTemplate, Any]:
85
79
  return SANKEY_STYLE_TEMPLATE, fplot_sankey
86
80
 
87
81
 
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
82
  def aplot_histogram(*args: Any, **kwargs: Any) -> Axes:
125
83
  from .histogram import aplot_histogram as _aplot_histogram
126
84
 
@@ -343,7 +301,7 @@ class DataFrameAccessor:
343
301
  Axes
344
302
  The Matplotlib axes object with the plot.
345
303
  """
346
- bubble_style_template, Bubble = _bubble_imports()
304
+ from .bubble import Bubble, BUBBLE_STYLE_TEMPLATE
347
305
 
348
306
  return Bubble(
349
307
  pd_df=self._obj,
@@ -357,7 +315,7 @@ class DataFrameAccessor:
357
315
  ascending=ascending,
358
316
  ).aplot(
359
317
  title=title,
360
- style=style or bubble_style_template,
318
+ style=style or BUBBLE_STYLE_TEMPLATE,
361
319
  hline=hline,
362
320
  vline=vline,
363
321
  ax=ax,
@@ -415,7 +373,7 @@ class DataFrameAccessor:
415
373
  Figure
416
374
  The new Matplotlib figure with the plot.
417
375
  """
418
- bubble_style_template, Bubble = _bubble_imports()
376
+ from .bubble import Bubble, BUBBLE_STYLE_TEMPLATE
419
377
 
420
378
  return Bubble(
421
379
  pd_df=self._obj,
@@ -428,16 +386,8 @@ class DataFrameAccessor:
428
386
  max_values=max_values,
429
387
  center_to_mean=center_to_mean,
430
388
  ).fplot(
431
- label=label,
432
- x=x,
433
- y=y,
434
- z=z,
435
389
  title=title,
436
- style=style or bubble_style_template,
437
- max_values=max_values,
438
- center_to_mean=center_to_mean,
439
- sort_by=sort_by,
440
- ascending=ascending,
390
+ style=style or BUBBLE_STYLE_TEMPLATE,
441
391
  hline=hline,
442
392
  vline=vline,
443
393
  figsize=figsize,
@@ -492,16 +442,16 @@ class DataFrameAccessor:
492
442
  Figure
493
443
  The new Matplotlib figure with the composite plot.
494
444
  """
495
- bubble_style_template, _ = _bubble_imports()
445
+ from .composite import plot_composite_bubble as _plot_composite_bubble
496
446
 
497
- return plot_composite_bubble(
447
+ return _plot_composite_bubble(
498
448
  pd_df=self._obj,
499
449
  label=label,
500
450
  x=x,
501
451
  y=y,
502
452
  z=z,
503
453
  title=title,
504
- style=style or bubble_style_template,
454
+ style=style,
505
455
  max_values=max_values,
506
456
  center_to_mean=center_to_mean,
507
457
  sort_by=sort_by,
@@ -509,96 +459,6 @@ class DataFrameAccessor:
509
459
  table_rows=table_rows,
510
460
  )
511
461
 
512
- def aplot_bar(
513
- self,
514
- category: str,
515
- value: str,
516
- group: Optional[str] = None,
517
- stacked: bool = False,
518
- title: Optional[str] = None,
519
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
520
- ax: Optional[Axes] = None,
521
- ) -> Axes:
522
- """Plot bar or stacked bar charts on existing axes.
523
-
524
- Parameters
525
- ----------
526
- category : str
527
- Column to plot along the x-axis.
528
- value : str
529
- Column representing bar heights.
530
- group : str, optional
531
- Optional grouping column for multiple series.
532
- stacked : bool, optional
533
- Whether to stack grouped bars. The default is ``False``.
534
- title : str, optional
535
- Chart title.
536
- style : StyleTemplate, optional
537
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
538
- ax : Axes, optional
539
- Matplotlib axes to plot on. If None, uses the current axes.
540
-
541
- Returns
542
- -------
543
- Axes
544
- The Matplotlib axes object with the bar chart.
545
- """
546
- return aplot_bar(
547
- pd_df=self._obj,
548
- category=category,
549
- value=value,
550
- group=group,
551
- stacked=stacked,
552
- title=title,
553
- style=style or DISTRIBUTION_STYLE_TEMPLATE,
554
- ax=ax,
555
- )
556
-
557
- def fplot_bar(
558
- self,
559
- category: str,
560
- value: str,
561
- group: Optional[str] = None,
562
- stacked: bool = False,
563
- title: Optional[str] = None,
564
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
565
- figsize: Tuple[float, float] = FIG_SIZE,
566
- ) -> Figure:
567
- """Plot bar or stacked bar charts on a new figure.
568
-
569
- Parameters
570
- ----------
571
- category : str
572
- Column to plot along the x-axis.
573
- value : str
574
- Column representing bar heights.
575
- group : str, optional
576
- Optional grouping column for multiple series.
577
- stacked : bool, optional
578
- Whether to stack grouped bars. The default is ``False``.
579
- title : str, optional
580
- Chart title.
581
- style : StyleTemplate, optional
582
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
583
- figsize : tuple[float, float], optional
584
- Figure size. The default is FIG_SIZE.
585
-
586
- Returns
587
- -------
588
- Figure
589
- The new Matplotlib figure with the bar chart.
590
- """
591
- return fplot_bar(
592
- pd_df=self._obj,
593
- category=category,
594
- value=value,
595
- group=group,
596
- stacked=stacked,
597
- title=title,
598
- style=style,
599
- figsize=figsize,
600
- )
601
-
602
462
  def aplot_histogram_kde(
603
463
  self,
604
464
  column: str,
@@ -681,88 +541,6 @@ class DataFrameAccessor:
681
541
  figsize=figsize,
682
542
  )
683
543
 
684
- def aplot_box_violin(
685
- self,
686
- column: str,
687
- by: Optional[str] = None,
688
- violin: bool = False,
689
- title: Optional[str] = None,
690
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
691
- ax: Optional[Axes] = None,
692
- ) -> Axes:
693
- """Plot box or violin charts on existing axes.
694
-
695
- Parameters
696
- ----------
697
- column : str
698
- Column to summarize.
699
- by : str, optional
700
- Optional grouping column.
701
- violin : bool, optional
702
- Whether to draw a violin plot. The default is ``False``.
703
- title : str, optional
704
- Chart title.
705
- style : StyleTemplate, optional
706
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
707
- ax : Axes, optional
708
- Matplotlib axes to plot on. If None, uses the current axes.
709
-
710
- Returns
711
- -------
712
- Axes
713
- The Matplotlib axes object with the distribution summary.
714
- """
715
- return aplot_box_violin(
716
- pd_df=self._obj,
717
- column=column,
718
- by=by,
719
- violin=violin,
720
- title=title,
721
- style=style,
722
- ax=ax,
723
- )
724
-
725
- def fplot_box_violin(
726
- self,
727
- column: str,
728
- by: Optional[str] = None,
729
- violin: bool = False,
730
- title: Optional[str] = None,
731
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
732
- figsize: Tuple[float, float] = FIG_SIZE,
733
- ) -> Figure:
734
- """Plot box or violin charts on a new figure.
735
-
736
- Parameters
737
- ----------
738
- column : str
739
- Column to summarize.
740
- by : str, optional
741
- Optional grouping column.
742
- violin : bool, optional
743
- Whether to draw a violin plot. The default is ``False``.
744
- title : str, optional
745
- Chart title.
746
- style : StyleTemplate, optional
747
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
748
- figsize : tuple[float, float], optional
749
- Figure size. The default is FIG_SIZE.
750
-
751
- Returns
752
- -------
753
- Figure
754
- The new Matplotlib figure with the distribution summary.
755
- """
756
- return fplot_box_violin(
757
- pd_df=self._obj,
758
- column=column,
759
- by=by,
760
- violin=violin,
761
- title=title,
762
- style=style,
763
- figsize=figsize,
764
- )
765
-
766
544
  def aplot_heatmap(
767
545
  self,
768
546
  x: str,
@@ -794,9 +572,9 @@ class DataFrameAccessor:
794
572
  Axes
795
573
  The Matplotlib axes object with the heatmap.
796
574
  """
797
- heatmap_style_template, _, aplot_heatmap, _, _ = _heatmap_imports()
575
+ from .heatmap import aplot_heatmap as _aplot_heatmap
798
576
 
799
- return aplot_heatmap(
577
+ return _aplot_heatmap(
800
578
  pd_df=self._obj,
801
579
  x=x,
802
580
  y=y,
@@ -837,21 +615,23 @@ class DataFrameAccessor:
837
615
  Figure
838
616
  The new Matplotlib figure with the heatmap.
839
617
  """
840
- heatmap_style_template, _, _, _, fplot_heatmap = _heatmap_imports()
618
+ from .heatmap import fplot_heatmap as _fplot_heatmap
841
619
 
842
- return fplot_heatmap(
620
+ return _fplot_heatmap(
843
621
  pd_df=self._obj,
844
622
  x=x,
845
623
  y=y,
846
624
  value=value,
847
625
  title=title,
848
- style=style or heatmap_style_template,
626
+ style=style,
849
627
  figsize=figsize,
850
628
  )
851
629
 
852
630
  def aplot_correlation_matrix(
853
631
  self,
854
- columns: Optional[List[str]] = None,
632
+ x: str,
633
+ y: str,
634
+ value: str,
855
635
  method: CorrelationMethod = "pearson",
856
636
  title: Optional[str] = None,
857
637
  style: Optional[StyleTemplate] = None,
@@ -877,17 +657,60 @@ class DataFrameAccessor:
877
657
  Axes
878
658
  The Matplotlib axes object with the correlation matrix.
879
659
  """
880
- heatmap_style_template, aplot_correlation_matrix, _, _, _ = _heatmap_imports()
660
+ from .heatmap import aplot_correlation_matrix as _aplot_correlation_matrix
881
661
 
882
- return aplot_correlation_matrix(
662
+ return _aplot_correlation_matrix(
883
663
  pd_df=self._obj,
884
- columns=columns,
664
+ x=x,
665
+ y=y,
666
+ value=value,
885
667
  method=method,
886
668
  title=title,
887
- style=style or DISTRIBUTION_STYLE_TEMPLATE,
669
+ style=style,
888
670
  ax=ax,
889
671
  )
890
672
 
673
+ def fplot_correlation_matrix(
674
+ self,
675
+ x: str,
676
+ y: str,
677
+ value: str,
678
+ method: CorrelationMethod = "pearson",
679
+ title: Optional[str] = None,
680
+ style: Optional[StyleTemplate] = None,
681
+ ) -> Figure:
682
+ """Plot a correlation matrix heatmap.
683
+
684
+ Parameters
685
+ ----------
686
+ columns : list[str], optional
687
+ Numeric columns to include. The default is ``None`` for all numeric columns.
688
+ method : CorrelationMethod, optional
689
+ Correlation method. The default is "pearson".
690
+ title : str, optional
691
+ Chart title.
692
+ style : StyleTemplate, optional
693
+ Styling template. The default is ``HEATMAP_STYLE_TEMPLATE``.
694
+ ax : Axes, optional
695
+ Matplotlib axes to plot on. If None, uses the current axes.
696
+
697
+ Returns
698
+ -------
699
+ Axes
700
+ The Matplotlib axes object with the correlation matrix.
701
+ """
702
+ from .heatmap import fplot_correlation_matrix as _fplot_correlation_matrix
703
+
704
+ return _fplot_correlation_matrix(
705
+ pd_df=self._obj,
706
+ x=x,
707
+ y=y,
708
+ value=value,
709
+ title=title,
710
+ style=style,
711
+ correlation_method=method,
712
+ )
713
+
891
714
  def aplot_area(
892
715
  self,
893
716
  x: str,
@@ -895,42 +718,48 @@ class DataFrameAccessor:
895
718
  label: Optional[str] = None,
896
719
  stacked: bool = True,
897
720
  title: Optional[str] = None,
898
- style: StyleTemplate = AREA_STYLE_TEMPLATE,
721
+ style: Optional[StyleTemplate] = None,
899
722
  ax: Optional[Axes] = None,
723
+ **kwargs: Any,
900
724
  ) -> Axes:
901
- """Plot an area chart on existing axes.
725
+ """Plot an area chart, optionally stacked.
902
726
 
903
727
  Parameters
904
728
  ----------
905
729
  x : str
906
- Column for the x-axis.
730
+ Column used for x-axis values.
907
731
  y : str
908
- Column for the area heights.
732
+ Column used for y-axis values.
909
733
  label : str, optional
910
- Optional grouping column.
734
+ Column used to split areas into groups. The default is ``None``.
911
735
  stacked : bool, optional
912
- Whether to stack grouped areas. The default is ``True``.
736
+ Whether grouped areas are stacked. The default is ``True``.
913
737
  title : str, optional
914
738
  Chart title.
915
739
  style : StyleTemplate, optional
916
740
  Styling template. The default is ``AREA_STYLE_TEMPLATE``.
917
741
  ax : Axes, optional
918
742
  Matplotlib axes to plot on. If None, uses the current axes.
743
+ **kwargs : Any
744
+ Additional keyword arguments forwarded to the area plotter.
919
745
 
920
746
  Returns
921
747
  -------
922
748
  Axes
923
749
  The Matplotlib axes object with the area chart.
924
750
  """
925
- return aplot_area(
751
+ from .area import aplot_area as _aplot_area
752
+
753
+ return _aplot_area(
926
754
  pd_df=self._obj,
927
755
  x=x,
928
756
  y=y,
929
757
  label=label,
930
758
  stacked=stacked,
931
759
  title=title,
932
- style=style,
760
+ style=style or AREA_STYLE_TEMPLATE,
933
761
  ax=ax,
762
+ **kwargs,
934
763
  )
935
764
 
936
765
  def fplot_area(
@@ -940,42 +769,48 @@ class DataFrameAccessor:
940
769
  label: Optional[str] = None,
941
770
  stacked: bool = True,
942
771
  title: Optional[str] = None,
943
- style: StyleTemplate = AREA_STYLE_TEMPLATE,
772
+ style: Optional[StyleTemplate] = None,
944
773
  figsize: Tuple[float, float] = FIG_SIZE,
774
+ **kwargs: Any,
945
775
  ) -> Figure:
946
- """Plot an area chart on a new figure.
776
+ """Plot an area chart, optionally stacked, on a new figure.
947
777
 
948
778
  Parameters
949
779
  ----------
950
780
  x : str
951
- Column for the x-axis.
781
+ Column used for x-axis values.
952
782
  y : str
953
- Column for the area heights.
783
+ Column used for y-axis values.
954
784
  label : str, optional
955
- Optional grouping column.
785
+ Column used to split areas into groups. The default is ``None``.
956
786
  stacked : bool, optional
957
- Whether to stack grouped areas. The default is ``True``.
787
+ Whether grouped areas are stacked. The default is ``True``.
958
788
  title : str, optional
959
789
  Chart title.
960
790
  style : StyleTemplate, optional
961
791
  Styling template. The default is ``AREA_STYLE_TEMPLATE``.
962
792
  figsize : tuple[float, float], optional
963
793
  Figure size. The default is FIG_SIZE.
794
+ **kwargs : Any
795
+ Additional keyword arguments forwarded to the area plotter.
964
796
 
965
797
  Returns
966
798
  -------
967
799
  Figure
968
800
  The new Matplotlib figure with the area chart.
969
801
  """
970
- return fplot_area(
802
+ from .area import fplot_area as _fplot_area
803
+
804
+ return _fplot_area(
971
805
  pd_df=self._obj,
972
806
  x=x,
973
807
  y=y,
974
808
  label=label,
975
809
  stacked=stacked,
976
810
  title=title,
977
- style=style,
811
+ style=style or AREA_STYLE_TEMPLATE,
978
812
  figsize=figsize,
813
+ **kwargs,
979
814
  )
980
815
 
981
816
  def aplot_pie_donut(
@@ -1487,67 +1322,6 @@ class DataFrameAccessor:
1487
1322
  figsize=figsize,
1488
1323
  )
1489
1324
 
1490
- def aplot_network(
1491
- self,
1492
- edge_source_col: str = "source",
1493
- edge_target_col: str = "target",
1494
- edge_weight_col: str = "weight",
1495
- title: Optional[str] = None,
1496
- style: Optional[StyleTemplate] = None,
1497
- layout_seed: Optional[int] = None,
1498
- ax: Optional[Axes] = None,
1499
- ) -> Axes:
1500
- """Plot a network graph on a Matplotlib axes.
1501
-
1502
- Parameters
1503
- ----------
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
1509
- Column for source nodes. The default is "source".
1510
- edge_target_col : str, optional
1511
- Column for target nodes. The default is "target".
1512
- edge_weight_col : str, optional
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.
1520
- title : str, optional
1521
- Chart title.
1522
- style : StyleTemplate, optional
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
1325
  def aplot_network_node(
1552
1326
  self,
1553
1327
  node: Any,
@@ -1680,67 +1454,6 @@ class DataFrameAccessor:
1680
1454
  **kwargs,
1681
1455
  )
1682
1456
 
1683
- def fplot_network(
1684
- self,
1685
- edge_source_col: str = "source",
1686
- edge_target_col: str = "target",
1687
- edge_weight_col: str = "weight",
1688
- title: Optional[str] = None,
1689
- style: Optional[StyleTemplate] = None,
1690
- layout_seed: Optional[int] = None,
1691
- figsize: Tuple[float, float] = FIG_SIZE,
1692
- ) -> Figure:
1693
- """Plot a network graph on a new figure.
1694
-
1695
- Parameters
1696
- ----------
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
1702
- Column for source nodes. The default is "source".
1703
- edge_target_col : str, optional
1704
- Column for target nodes. The default is "target".
1705
- edge_weight_col : str, optional
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.
1713
- title : str, optional
1714
- Chart title.
1715
- style : StyleTemplate, optional
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
1457
  def fplot_network_node(
1745
1458
  self,
1746
1459
  node: Any,