MatplotLibAPI 4.0.1__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,
@@ -429,7 +387,7 @@ class DataFrameAccessor:
429
387
  center_to_mean=center_to_mean,
430
388
  ).fplot(
431
389
  title=title,
432
- style=style or bubble_style_template,
390
+ style=style or BUBBLE_STYLE_TEMPLATE,
433
391
  hline=hline,
434
392
  vline=vline,
435
393
  figsize=figsize,
@@ -484,16 +442,16 @@ class DataFrameAccessor:
484
442
  Figure
485
443
  The new Matplotlib figure with the composite plot.
486
444
  """
487
- bubble_style_template, _ = _bubble_imports()
445
+ from .composite import plot_composite_bubble as _plot_composite_bubble
488
446
 
489
- return plot_composite_bubble(
447
+ return _plot_composite_bubble(
490
448
  pd_df=self._obj,
491
449
  label=label,
492
450
  x=x,
493
451
  y=y,
494
452
  z=z,
495
453
  title=title,
496
- style=style or bubble_style_template,
454
+ style=style,
497
455
  max_values=max_values,
498
456
  center_to_mean=center_to_mean,
499
457
  sort_by=sort_by,
@@ -501,96 +459,6 @@ class DataFrameAccessor:
501
459
  table_rows=table_rows,
502
460
  )
503
461
 
504
- def aplot_bar(
505
- self,
506
- category: str,
507
- value: str,
508
- group: Optional[str] = None,
509
- stacked: bool = False,
510
- title: Optional[str] = None,
511
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
512
- ax: Optional[Axes] = None,
513
- ) -> Axes:
514
- """Plot bar or stacked bar charts on existing axes.
515
-
516
- Parameters
517
- ----------
518
- category : str
519
- Column to plot along the x-axis.
520
- value : str
521
- Column representing bar heights.
522
- group : str, optional
523
- Optional grouping column for multiple series.
524
- stacked : bool, optional
525
- Whether to stack grouped bars. The default is ``False``.
526
- title : str, optional
527
- Chart title.
528
- style : StyleTemplate, optional
529
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
530
- ax : Axes, optional
531
- Matplotlib axes to plot on. If None, uses the current axes.
532
-
533
- Returns
534
- -------
535
- Axes
536
- The Matplotlib axes object with the bar chart.
537
- """
538
- return aplot_bar(
539
- pd_df=self._obj,
540
- category=category,
541
- value=value,
542
- group=group,
543
- stacked=stacked,
544
- title=title,
545
- style=style or DISTRIBUTION_STYLE_TEMPLATE,
546
- ax=ax,
547
- )
548
-
549
- def fplot_bar(
550
- self,
551
- category: str,
552
- value: str,
553
- group: Optional[str] = None,
554
- stacked: bool = False,
555
- title: Optional[str] = None,
556
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
557
- figsize: Tuple[float, float] = FIG_SIZE,
558
- ) -> Figure:
559
- """Plot bar or stacked bar charts on a new figure.
560
-
561
- Parameters
562
- ----------
563
- category : str
564
- Column to plot along the x-axis.
565
- value : str
566
- Column representing bar heights.
567
- group : str, optional
568
- Optional grouping column for multiple series.
569
- stacked : bool, optional
570
- Whether to stack grouped bars. The default is ``False``.
571
- title : str, optional
572
- Chart title.
573
- style : StyleTemplate, optional
574
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
575
- figsize : tuple[float, float], optional
576
- Figure size. The default is FIG_SIZE.
577
-
578
- Returns
579
- -------
580
- Figure
581
- The new Matplotlib figure with the bar chart.
582
- """
583
- return fplot_bar(
584
- pd_df=self._obj,
585
- category=category,
586
- value=value,
587
- group=group,
588
- stacked=stacked,
589
- title=title,
590
- style=style,
591
- figsize=figsize,
592
- )
593
-
594
462
  def aplot_histogram_kde(
595
463
  self,
596
464
  column: str,
@@ -673,88 +541,6 @@ class DataFrameAccessor:
673
541
  figsize=figsize,
674
542
  )
675
543
 
676
- def aplot_box_violin(
677
- self,
678
- column: str,
679
- by: Optional[str] = None,
680
- violin: bool = False,
681
- title: Optional[str] = None,
682
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
683
- ax: Optional[Axes] = None,
684
- ) -> Axes:
685
- """Plot box or violin charts on existing axes.
686
-
687
- Parameters
688
- ----------
689
- column : str
690
- Column to summarize.
691
- by : str, optional
692
- Optional grouping column.
693
- violin : bool, optional
694
- Whether to draw a violin plot. The default is ``False``.
695
- title : str, optional
696
- Chart title.
697
- style : StyleTemplate, optional
698
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
699
- ax : Axes, optional
700
- Matplotlib axes to plot on. If None, uses the current axes.
701
-
702
- Returns
703
- -------
704
- Axes
705
- The Matplotlib axes object with the distribution summary.
706
- """
707
- return aplot_box_violin(
708
- pd_df=self._obj,
709
- column=column,
710
- by=by,
711
- violin=violin,
712
- title=title,
713
- style=style,
714
- ax=ax,
715
- )
716
-
717
- def fplot_box_violin(
718
- self,
719
- column: str,
720
- by: Optional[str] = None,
721
- violin: bool = False,
722
- title: Optional[str] = None,
723
- style: StyleTemplate = DISTRIBUTION_STYLE_TEMPLATE,
724
- figsize: Tuple[float, float] = FIG_SIZE,
725
- ) -> Figure:
726
- """Plot box or violin charts on a new figure.
727
-
728
- Parameters
729
- ----------
730
- column : str
731
- Column to summarize.
732
- by : str, optional
733
- Optional grouping column.
734
- violin : bool, optional
735
- Whether to draw a violin plot. The default is ``False``.
736
- title : str, optional
737
- Chart title.
738
- style : StyleTemplate, optional
739
- Styling template. The default is ``DISTRIBUTION_STYLE_TEMPLATE``.
740
- figsize : tuple[float, float], optional
741
- Figure size. The default is FIG_SIZE.
742
-
743
- Returns
744
- -------
745
- Figure
746
- The new Matplotlib figure with the distribution summary.
747
- """
748
- return fplot_box_violin(
749
- pd_df=self._obj,
750
- column=column,
751
- by=by,
752
- violin=violin,
753
- title=title,
754
- style=style,
755
- figsize=figsize,
756
- )
757
-
758
544
  def aplot_heatmap(
759
545
  self,
760
546
  x: str,
@@ -786,9 +572,9 @@ class DataFrameAccessor:
786
572
  Axes
787
573
  The Matplotlib axes object with the heatmap.
788
574
  """
789
- heatmap_style_template, _, aplot_heatmap, _, _ = _heatmap_imports()
575
+ from .heatmap import aplot_heatmap as _aplot_heatmap
790
576
 
791
- return aplot_heatmap(
577
+ return _aplot_heatmap(
792
578
  pd_df=self._obj,
793
579
  x=x,
794
580
  y=y,
@@ -829,21 +615,23 @@ class DataFrameAccessor:
829
615
  Figure
830
616
  The new Matplotlib figure with the heatmap.
831
617
  """
832
- heatmap_style_template, _, _, _, fplot_heatmap = _heatmap_imports()
618
+ from .heatmap import fplot_heatmap as _fplot_heatmap
833
619
 
834
- return fplot_heatmap(
620
+ return _fplot_heatmap(
835
621
  pd_df=self._obj,
836
622
  x=x,
837
623
  y=y,
838
624
  value=value,
839
625
  title=title,
840
- style=style or heatmap_style_template,
626
+ style=style,
841
627
  figsize=figsize,
842
628
  )
843
629
 
844
630
  def aplot_correlation_matrix(
845
631
  self,
846
- columns: Optional[List[str]] = None,
632
+ x: str,
633
+ y: str,
634
+ value: str,
847
635
  method: CorrelationMethod = "pearson",
848
636
  title: Optional[str] = None,
849
637
  style: Optional[StyleTemplate] = None,
@@ -869,17 +657,60 @@ class DataFrameAccessor:
869
657
  Axes
870
658
  The Matplotlib axes object with the correlation matrix.
871
659
  """
872
- heatmap_style_template, aplot_correlation_matrix, _, _, _ = _heatmap_imports()
660
+ from .heatmap import aplot_correlation_matrix as _aplot_correlation_matrix
873
661
 
874
- return aplot_correlation_matrix(
662
+ return _aplot_correlation_matrix(
875
663
  pd_df=self._obj,
876
- columns=columns,
664
+ x=x,
665
+ y=y,
666
+ value=value,
877
667
  method=method,
878
668
  title=title,
879
- style=style or DISTRIBUTION_STYLE_TEMPLATE,
669
+ style=style,
880
670
  ax=ax,
881
671
  )
882
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
+
883
714
  def aplot_area(
884
715
  self,
885
716
  x: str,
@@ -887,22 +718,22 @@ class DataFrameAccessor:
887
718
  label: Optional[str] = None,
888
719
  stacked: bool = True,
889
720
  title: Optional[str] = None,
890
- style: StyleTemplate = AREA_STYLE_TEMPLATE,
721
+ style: Optional[StyleTemplate] = None,
891
722
  ax: Optional[Axes] = None,
892
723
  **kwargs: Any,
893
724
  ) -> Axes:
894
- """Plot an area chart on existing axes.
725
+ """Plot an area chart, optionally stacked.
895
726
 
896
727
  Parameters
897
728
  ----------
898
729
  x : str
899
- Column for the x-axis.
730
+ Column used for x-axis values.
900
731
  y : str
901
- Column for the area heights.
732
+ Column used for y-axis values.
902
733
  label : str, optional
903
- Optional grouping column.
734
+ Column used to split areas into groups. The default is ``None``.
904
735
  stacked : bool, optional
905
- Whether to stack grouped areas. The default is ``True``.
736
+ Whether grouped areas are stacked. The default is ``True``.
906
737
  title : str, optional
907
738
  Chart title.
908
739
  style : StyleTemplate, optional
@@ -910,21 +741,23 @@ class DataFrameAccessor:
910
741
  ax : Axes, optional
911
742
  Matplotlib axes to plot on. If None, uses the current axes.
912
743
  **kwargs : Any
913
- Additional keyword arguments forwarded to the underlying area plot call.
744
+ Additional keyword arguments forwarded to the area plotter.
914
745
 
915
746
  Returns
916
747
  -------
917
748
  Axes
918
749
  The Matplotlib axes object with the area chart.
919
750
  """
920
- return aplot_area(
921
- self._obj,
922
- x,
923
- y,
751
+ from .area import aplot_area as _aplot_area
752
+
753
+ return _aplot_area(
754
+ pd_df=self._obj,
755
+ x=x,
756
+ y=y,
924
757
  label=label,
925
758
  stacked=stacked,
926
759
  title=title,
927
- style=style,
760
+ style=style or AREA_STYLE_TEMPLATE,
928
761
  ax=ax,
929
762
  **kwargs,
930
763
  )
@@ -936,22 +769,22 @@ class DataFrameAccessor:
936
769
  label: Optional[str] = None,
937
770
  stacked: bool = True,
938
771
  title: Optional[str] = None,
939
- style: StyleTemplate = AREA_STYLE_TEMPLATE,
772
+ style: Optional[StyleTemplate] = None,
940
773
  figsize: Tuple[float, float] = FIG_SIZE,
941
774
  **kwargs: Any,
942
775
  ) -> Figure:
943
- """Plot an area chart on a new figure.
776
+ """Plot an area chart, optionally stacked, on a new figure.
944
777
 
945
778
  Parameters
946
779
  ----------
947
780
  x : str
948
- Column for the x-axis.
781
+ Column used for x-axis values.
949
782
  y : str
950
- Column for the area heights.
783
+ Column used for y-axis values.
951
784
  label : str, optional
952
- Optional grouping column.
785
+ Column used to split areas into groups. The default is ``None``.
953
786
  stacked : bool, optional
954
- Whether to stack grouped areas. The default is ``True``.
787
+ Whether grouped areas are stacked. The default is ``True``.
955
788
  title : str, optional
956
789
  Chart title.
957
790
  style : StyleTemplate, optional
@@ -959,21 +792,23 @@ class DataFrameAccessor:
959
792
  figsize : tuple[float, float], optional
960
793
  Figure size. The default is FIG_SIZE.
961
794
  **kwargs : Any
962
- Additional keyword arguments forwarded to the underlying area plot call.
795
+ Additional keyword arguments forwarded to the area plotter.
963
796
 
964
797
  Returns
965
798
  -------
966
799
  Figure
967
800
  The new Matplotlib figure with the area chart.
968
801
  """
969
- return fplot_area(
970
- self._obj,
971
- x,
972
- y,
802
+ from .area import fplot_area as _fplot_area
803
+
804
+ return _fplot_area(
805
+ pd_df=self._obj,
806
+ x=x,
807
+ y=y,
973
808
  label=label,
974
809
  stacked=stacked,
975
810
  title=title,
976
- style=style,
811
+ style=style or AREA_STYLE_TEMPLATE,
977
812
  figsize=figsize,
978
813
  **kwargs,
979
814
  )
@@ -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,