1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
| from __future__ import annotations
|
| from typing import TYPE_CHECKING
|
| from pandas.plotting._matplotlib.boxplot import (
| BoxPlot,
| boxplot,
| boxplot_frame,
| boxplot_frame_groupby,
| )
| from pandas.plotting._matplotlib.converter import (
| deregister,
| register,
| )
| from pandas.plotting._matplotlib.core import (
| AreaPlot,
| BarhPlot,
| BarPlot,
| HexBinPlot,
| LinePlot,
| PiePlot,
| ScatterPlot,
| )
| from pandas.plotting._matplotlib.hist import (
| HistPlot,
| KdePlot,
| hist_frame,
| hist_series,
| )
| from pandas.plotting._matplotlib.misc import (
| andrews_curves,
| autocorrelation_plot,
| bootstrap_plot,
| lag_plot,
| parallel_coordinates,
| radviz,
| scatter_matrix,
| )
| from pandas.plotting._matplotlib.tools import table
|
| if TYPE_CHECKING:
| from pandas.plotting._matplotlib.core import MPLPlot
|
| PLOT_CLASSES: dict[str, type[MPLPlot]] = {
| "line": LinePlot,
| "bar": BarPlot,
| "barh": BarhPlot,
| "box": BoxPlot,
| "hist": HistPlot,
| "kde": KdePlot,
| "area": AreaPlot,
| "pie": PiePlot,
| "scatter": ScatterPlot,
| "hexbin": HexBinPlot,
| }
|
|
| def plot(data, kind, **kwargs):
| # Importing pyplot at the top of the file (before the converters are
| # registered) causes problems in matplotlib 2 (converters seem to not
| # work)
| import matplotlib.pyplot as plt
|
| if kwargs.pop("reuse_plot", False):
| ax = kwargs.get("ax")
| if ax is None and len(plt.get_fignums()) > 0:
| with plt.rc_context():
| ax = plt.gca()
| kwargs["ax"] = getattr(ax, "left_ax", ax)
| plot_obj = PLOT_CLASSES[kind](data, **kwargs)
| plot_obj.generate()
| plot_obj.draw()
| return plot_obj.result
|
|
| __all__ = [
| "plot",
| "hist_series",
| "hist_frame",
| "boxplot",
| "boxplot_frame",
| "boxplot_frame_groupby",
| "table",
| "andrews_curves",
| "autocorrelation_plot",
| "bootstrap_plot",
| "lag_plot",
| "parallel_coordinates",
| "radviz",
| "scatter_matrix",
| "register",
| "deregister",
| ]
|
|