MatplotLibAPI 3.2.13__py3-none-any.whl → 3.2.14__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 CHANGED
@@ -1,325 +1,850 @@
1
+ """Public API and pandas accessor for MatplotLibAPI."""
1
2
 
2
- from .StyleTemplate import StyleTemplate
3
- from .Bubble import aplot_bubble, fplot_bubble, BUBBLE_STYLE_TEMPLATE
4
- from .Composite import plot_composite_bubble,plot_composite_treemap
5
- from .Timeserie import aplot_timeserie, fplot_timeserie, TIMESERIE_STYLE_TEMPLATE
6
- from .Table import aplot_table, fplot_table, TABLE_STYLE_TEMPLATE
7
- from .Network import aplot_network, aplot_network_components, fplot_network, NETWORK_STYLE_TEMPLATE
8
- from .Treemap import fplot_treemap, aplot_treemap, TREEMAP_STYLE_TEMPLATE
9
- from typing import List, Optional, Tuple,Dict
10
- import pandas as pd
11
- from pandas.api.extensions import register_dataframe_accessor
3
+ from typing import Dict, List, Optional, Tuple
12
4
 
5
+ import numpy as np
6
+ import pandas as pd
7
+ import plotly.graph_objects as go
13
8
  from matplotlib.axes import Axes
14
9
  from matplotlib.figure import Figure
15
- import plotly.graph_objects as go
10
+ from pandas.api.extensions import register_dataframe_accessor
11
+
12
+ from .Bubble import BUBBLE_STYLE_TEMPLATE, aplot_bubble, fplot_bubble
13
+ from .Composite import plot_composite_bubble, plot_composite_treemap
14
+ from .Network import (
15
+ NETWORK_STYLE_TEMPLATE,
16
+ aplot_network,
17
+ aplot_network_components,
18
+ fplot_network,
19
+ )
20
+ from .StyleTemplate import StyleTemplate
21
+ from .Table import TABLE_STYLE_TEMPLATE, aplot_table, fplot_table
22
+ from .Timeserie import TIMESERIE_STYLE_TEMPLATE, aplot_timeserie, fplot_timeserie
23
+ from .Treemap import TREEMAP_STYLE_TEMPLATE, aplot_treemap, fplot_treemap
24
+ from .Wordcloud import WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud, fplot_wordcloud
16
25
 
17
26
 
18
27
  @register_dataframe_accessor("mpl")
19
28
  class DataFrameAccessor:
29
+ """Expose MatplotLibAPI plotting helpers as a pandas accessor.
30
+
31
+ Methods
32
+ -------
33
+ aplot_bubble
34
+ Plot a bubble chart using the underlying DataFrame.
35
+ fplot_bubble
36
+ Plot a bubble chart on a new figure.
37
+ fplot_composite_bubble
38
+ Plot a composite bubble chart with summary tables.
39
+ aplot_table
40
+ Plot a table of the DataFrame's data on a Matplotlib axes.
41
+ fplot_table
42
+ Plot a table of the DataFrame's data on a new figure.
43
+ aplot_timeserie
44
+ Plot a time series on a Matplotlib axes.
45
+ fplot_timeserie
46
+ Plot a time series on a new figure.
47
+ aplot_wordcloud
48
+ Plot a word cloud on a Matplotlib axes.
49
+ fplot_wordcloud
50
+ Plot a word cloud on a new figure.
51
+ aplot_network
52
+ Plot a network graph on a Matplotlib axes.
53
+ aplot_network_components
54
+ Plot connected components of a network graph on multiple axes.
55
+ fplot_network
56
+ Plot a network graph on a new figure.
57
+ fplot_treemap
58
+ Plot a treemap on a new Plotly figure.
59
+ fplot_composite_treemap
60
+ Plot a composite treemap on a new Plotly figure.
61
+ """
20
62
 
21
63
  def __init__(self, pd_df: pd.DataFrame):
64
+ """Store the parent DataFrame."""
22
65
  self._obj = pd_df
23
66
 
24
- def aplot_bubble(self,
25
- label: str,
26
- x: str,
27
- y: str,
28
- z: str,
29
- title: Optional[str] = None,
30
- style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
31
- max_values: int = 50,
32
- center_to_mean: bool = False,
33
- sort_by: Optional[str] = None,
34
- ascending: bool = False,
35
- hline: bool = False,
36
- vline: bool = False,
37
- ax: Optional[Axes] = None) -> Axes:
38
-
39
- return aplot_bubble(pd_df=self._obj,
40
- label=label,
41
- x=x,
42
- y=y,
43
- z=z,
44
- title=title,
45
- style=style,
46
- max_values=max_values,
47
- center_to_mean=center_to_mean,
48
- sort_by=sort_by,
49
- ascending=ascending,
50
- hline=hline,
51
- vline=vline,
52
- ax=ax)
53
-
54
- def fplot_bubble(self,
55
- label: str,
56
- x: str,
57
- y: str,
58
- z: str,
59
- title: Optional[str] = None,
60
- style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
61
- max_values: int = 50,
62
- center_to_mean: bool = False,
63
- sort_by: Optional[str] = None,
64
- ascending: bool = False,
65
- hline: bool = False,
66
- vline: bool = False,
67
- figsize: Tuple[float, float] = (19.2, 10.8)) -> Figure:
68
-
69
- return fplot_bubble(pd_df=self._obj,
70
- label=label,
71
- x=x,
72
- y=y,
73
- z=z,
74
- title=title,
75
- style=style,
76
- max_values=max_values,
77
- center_to_mean=center_to_mean,
78
- sort_by=sort_by,
79
- ascending=ascending,
80
- hline=hline,
81
- vline=vline,
82
- figsize=figsize)
83
-
84
- def fplot_composite_bubble(self,
85
- label: str,
86
- x: str,
87
- y: str,
88
- z: str,
89
- title: Optional[str] = None,
90
- style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
91
- max_values: int = 100,
92
- center_to_mean: bool = False,
93
- sort_by: Optional[str] = None,
94
- ascending: bool = False,
95
- table_rows:int=10) -> Figure:
96
-
97
- return plot_composite_bubble(pd_df=self._obj,
98
- label=label,
99
- x=x,
100
- y=y,
101
- z=z,
102
- title=title,
103
- style=style,
104
- max_values=max_values,
105
- center_to_mean=center_to_mean,
106
- sort_by=sort_by,
107
- ascending=ascending,
108
- table_rows=table_rows)
109
-
110
- def aplot_table(self,
111
- cols: List[str],
112
- title: Optional[str] = None,
113
- style: StyleTemplate = TABLE_STYLE_TEMPLATE,
114
- max_values: int = 20,
115
- sort_by: Optional[str] = None,
116
- ascending: bool = False,
117
- ax: Optional[Axes] = None) -> Axes:
118
-
119
- return aplot_table(pd_df=self._obj,
120
- cols=cols,
121
- title=title,
122
- style=style,
123
- max_values=max_values,
124
- sort_by=sort_by,
125
- ascending=ascending,
126
- ax=ax)
127
-
128
- def fplot_table(self,
129
- cols: List[str],
130
- title: Optional[str] = None,
131
- style: StyleTemplate = TABLE_STYLE_TEMPLATE,
132
- max_values: int = 20,
133
- sort_by: Optional[str] = None,
134
- ascending: bool = False,
135
- figsize: Tuple[float, float] = (19.2, 10.8)) -> Axes:
136
-
137
- return fplot_table(pd_df=self._obj,
138
- cols=cols,
139
- title=title,
140
- style=style,
141
- max_values=max_values,
142
- sort_by=sort_by,
143
- ascending=ascending,
144
- figsize=figsize)
145
-
146
- def aplot_timeserie(self,
147
- label: str,
148
- x: str,
149
- y: str,
150
- title: Optional[str] = None,
151
- style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
152
- max_values: int = 100,
153
- sort_by: Optional[str] = None,
154
- ascending: bool = False,
155
- std: bool = False,
156
- ax: Optional[Axes] = None) -> Axes:
157
-
158
- return aplot_timeserie(pd_df=self._obj,
159
- label=label,
160
- x=x,
161
- y=y,
162
- title=title,
163
- style=style,
164
- max_values=max_values,
165
- sort_by=sort_by,
166
- ascending=ascending,
167
- std=std,
168
- ax=ax)
169
-
170
- def fplot_timeserie(self,
171
- label: str,
172
- x: str,
173
- y: str,
174
- title: Optional[str] = None,
175
- style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
176
- max_values: int = 100,
177
- sort_by: Optional[str] = None,
178
- ascending: bool = False,
179
- std: bool = False,
180
- figsize: Tuple[float, float] = (19.2, 10.8)) -> Axes:
181
-
182
- return fplot_timeserie(pd_df=self._obj,
183
- label=label,
184
- x=x,
185
- y=y,
186
- title=title,
187
- style=style,
188
- max_values=max_values,
189
- sort_by=sort_by,
190
- ascending=ascending,
191
- std=std,
192
- figsize=figsize)
193
-
194
- def aplot_network(self,
195
- source: str = "source",
196
- target: str = "target",
197
- weight: str = "weight",
198
- title: Optional[str] = None,
199
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
200
- sort_by: Optional[str] = None,
201
- ascending: bool = False,
202
- node_list: Optional[List] = None,
203
- ax: Optional[Axes] = None) -> Axes:
204
-
205
- return aplot_network(pd_df=self._obj,
206
- source=source,
207
- target=target,
208
- weight=weight,
209
- title=title,
210
- style=style,
211
- sort_by=sort_by,
212
- ascending=ascending,
213
- node_list=node_list,
214
- ax=ax)
215
-
216
- def aplot_network_components(self,
217
- source: str = "source",
218
- target: str = "target",
219
- weight: str = "weight",
220
- title: Optional[str] = None,
221
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
222
- sort_by: Optional[str] = None,
223
- ascending: bool = False,
224
- node_list: Optional[List] = None,
225
- ax: Optional[Axes] = None) -> Axes:
226
-
227
- return aplot_network_components(df=self._obj,
228
- source=source,
229
- target=target,
230
- weight=weight,
231
- title=title,
232
- style=style,
233
- sort_by=sort_by,
234
- ascending=ascending,
235
- node_list=node_list,
236
- ax=ax)
237
-
238
- def fplot_network(self,
239
- source: str = "source",
240
- target: str = "target",
241
- weight: str = "weight",
242
- title: Optional[str] = None,
243
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
244
- sort_by: Optional[str] = None,
245
- ascending: bool = False,
246
- node_list: Optional[List] = None) -> Axes:
247
-
248
- return fplot_network(pd_df=self._obj,
249
- source=source,
250
- target=target,
251
- weight=weight,
252
- title=title,
253
- style=style,
254
- sort_by=sort_by,
255
- ascending=ascending,
256
- node_list=node_list)
257
-
258
- def fplot_treemap(self,
259
- path: str,
260
- values: str,
261
- style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
262
- title: Optional[str] = None,
263
- color: Optional[str] = None,
264
- sort_by: Optional[str] = None,
265
- max_values: int = 100,
266
- ascending: bool = False,
267
- fig: Optional[go.Figure] = None) -> go.Figure:
268
- return fplot_treemap(pd_df=self._obj,
269
- path=path,
270
- values=values,
271
- title=title,
272
- style=style,
273
- color=color,
274
- sort_by=sort_by,
275
- ascending=ascending,
276
- max_values=max_values,
277
- fig=fig)
278
-
279
- def aplot_treemap(self,
280
- path: str,
281
- values: str,
282
- style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
283
- title: Optional[str] = None,
284
- color: Optional[str] = None,
285
- sort_by: Optional[str] = None,
286
- max_values: int = 100,
287
- ascending: bool = False,
288
- fig: Optional[go.Figure] = None) -> go.Figure:
289
- return aplot_treemap(pd_df=self._obj,
290
- path=path,
291
- values=values,
292
- title=title,
293
- style=style,
294
- color=color,
295
- sort_by=sort_by,
296
- ascending=ascending,
297
- max_values=max_values)
298
-
299
- def fplot_composite_treemap(self,
300
- pathes: List[str],
301
- values: str,
302
- style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
303
- title: Optional[str] = None,
304
- color: Optional[str] = None,
305
- sort_by: Optional[str] = None,
306
- max_values: int = 100,
307
- ascending: bool = False,
308
- fig: Optional[go.Figure] = None) -> go.Figure:
309
- pd_dfs:Dict[str,pd.DataFrame]={}
310
- for path in pathes:
311
- pd_dfs[path]=self._obj
312
-
313
-
314
- return plot_composite_treemap(pd_dfs=pd_dfs,
315
- values=values,
316
- title=title,
317
- style=style,
318
- color=color,
319
- sort_by=sort_by,
320
- ascending=ascending,
321
- max_values=max_values)
322
-
323
-
324
- __all__ = ["validate_dataframe", "aplot_bubble", "aplot_timeserie", "aplot_table", "aplot_network", "aplot_network_components", "fplot_network",
325
- "plot_pivotbar", "fplot_treemap", "aplot_treemap", "plot_composite_bubble","plot_composite_treemap", "StyleTemplate", "DataFrameAccessor"]
67
+ def aplot_bubble(
68
+ self,
69
+ label: str,
70
+ x: str,
71
+ y: str,
72
+ z: str,
73
+ title: Optional[str] = None,
74
+ style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
75
+ max_values: int = 50,
76
+ center_to_mean: bool = False,
77
+ sort_by: Optional[str] = None,
78
+ ascending: bool = False,
79
+ hline: bool = False,
80
+ vline: bool = False,
81
+ ax: Optional[Axes] = None,
82
+ ) -> Axes:
83
+ """Plot a bubble chart using the underlying DataFrame.
84
+
85
+ Parameters
86
+ ----------
87
+ label : str
88
+ Column to use for bubble labels.
89
+ x : str
90
+ Column to use for the x-axis.
91
+ y : str
92
+ Column to use for the y-axis.
93
+ z : str
94
+ Column to use for the bubble size.
95
+ title : str, optional
96
+ Chart title.
97
+ style : StyleTemplate, optional
98
+ Styling template. The default is `BUBBLE_STYLE_TEMPLATE`.
99
+ max_values : int, optional
100
+ Maximum number of bubbles to plot. The default is 50.
101
+ center_to_mean : bool, optional
102
+ If True, center x-axis values around the mean. The default is `False`.
103
+ sort_by : str, optional
104
+ Column to sort by before plotting.
105
+ ascending : bool, optional
106
+ Sort order. The default is `False`.
107
+ hline : bool, optional
108
+ If True, draw a horizontal line at the mean of y-values. The default is `False`.
109
+ vline : bool, optional
110
+ If True, draw a vertical line at the mean of x-values. The default is `False`.
111
+ ax : Axes, optional
112
+ Matplotlib axes to plot on. If None, uses the current axes.
113
+
114
+ Returns
115
+ -------
116
+ Axes
117
+ The Matplotlib axes object with the plot.
118
+ """
119
+ return aplot_bubble(
120
+ pd_df=self._obj,
121
+ label=label,
122
+ x=x,
123
+ y=y,
124
+ z=z,
125
+ title=title,
126
+ style=style,
127
+ max_values=max_values,
128
+ center_to_mean=center_to_mean,
129
+ sort_by=sort_by,
130
+ ascending=ascending,
131
+ hline=hline,
132
+ vline=vline,
133
+ ax=ax,
134
+ )
135
+
136
+ def fplot_bubble(
137
+ self,
138
+ label: str,
139
+ x: str,
140
+ y: str,
141
+ z: str,
142
+ title: Optional[str] = None,
143
+ style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
144
+ max_values: int = 50,
145
+ center_to_mean: bool = False,
146
+ sort_by: Optional[str] = None,
147
+ ascending: bool = False,
148
+ hline: bool = False,
149
+ vline: bool = False,
150
+ figsize: Tuple[float, float] = (19.2, 10.8),
151
+ ) -> Figure:
152
+ """Plot a bubble chart on a new figure.
153
+
154
+ Parameters
155
+ ----------
156
+ label : str
157
+ Column to use for bubble labels.
158
+ x : str
159
+ Column to use for the x-axis.
160
+ y : str
161
+ Column to use for the y-axis.
162
+ z : str
163
+ Column to use for the bubble size.
164
+ title : str, optional
165
+ Chart title.
166
+ style : StyleTemplate, optional
167
+ Styling template. The default is `BUBBLE_STYLE_TEMPLATE`.
168
+ max_values : int, optional
169
+ Maximum number of bubbles to plot. The default is 50.
170
+ center_to_mean : bool, optional
171
+ If True, center x-axis values around the mean. The default is `False`.
172
+ sort_by : str, optional
173
+ Column to sort by before plotting.
174
+ ascending : bool, optional
175
+ Sort order. The default is `False`.
176
+ hline : bool, optional
177
+ If True, draw a horizontal line at the mean of y-values. The default is `False`.
178
+ vline : bool, optional
179
+ If True, draw a vertical line at the mean of x-values. The default is `False`.
180
+ figsize : tuple[float, float], optional
181
+ Figure size. The default is (19.2, 10.8).
182
+
183
+ Returns
184
+ -------
185
+ Figure
186
+ The new Matplotlib figure with the plot.
187
+ """
188
+ return fplot_bubble(
189
+ pd_df=self._obj,
190
+ label=label,
191
+ x=x,
192
+ y=y,
193
+ z=z,
194
+ title=title,
195
+ style=style,
196
+ max_values=max_values,
197
+ center_to_mean=center_to_mean,
198
+ sort_by=sort_by,
199
+ ascending=ascending,
200
+ hline=hline,
201
+ vline=vline,
202
+ figsize=figsize,
203
+ )
204
+
205
+ def fplot_composite_bubble(
206
+ self,
207
+ label: str,
208
+ x: str,
209
+ y: str,
210
+ z: str,
211
+ title: Optional[str] = None,
212
+ style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
213
+ max_values: int = 100,
214
+ center_to_mean: bool = False,
215
+ sort_by: Optional[str] = None,
216
+ ascending: bool = False,
217
+ table_rows: int = 10,
218
+ ) -> Figure:
219
+ """Plot a composite bubble chart with summary tables.
220
+
221
+ This plot combines a bubble chart with tables summarizing the
222
+ top and bottom rows of the dataset.
223
+
224
+ Parameters
225
+ ----------
226
+ label : str
227
+ Column to use for bubble labels.
228
+ x : str
229
+ Column to use for the x-axis.
230
+ y : str
231
+ Column to use for the y-axis.
232
+ z : str
233
+ Column to use for the bubble size.
234
+ title : str, optional
235
+ Chart title.
236
+ style : StyleTemplate, optional
237
+ Styling template. The default is `BUBBLE_STYLE_TEMPLATE`.
238
+ max_values : int, optional
239
+ Maximum number of bubbles to plot. The default is 100.
240
+ center_to_mean : bool, optional
241
+ If True, center x-axis values around the mean. The default is `False`.
242
+ sort_by : str, optional
243
+ Column to sort by before plotting.
244
+ ascending : bool, optional
245
+ Sort order. The default is `False`.
246
+ table_rows : int, optional
247
+ Number of rows for the summary tables. The default is 10.
248
+
249
+ Returns
250
+ -------
251
+ Figure
252
+ The new Matplotlib figure with the composite plot.
253
+ """
254
+ return plot_composite_bubble(
255
+ pd_df=self._obj,
256
+ label=label,
257
+ x=x,
258
+ y=y,
259
+ z=z,
260
+ title=title,
261
+ style=style,
262
+ max_values=max_values,
263
+ center_to_mean=center_to_mean,
264
+ sort_by=sort_by,
265
+ ascending=ascending,
266
+ table_rows=table_rows,
267
+ )
268
+
269
+ def aplot_table(
270
+ self,
271
+ cols: List[str],
272
+ title: Optional[str] = None,
273
+ style: StyleTemplate = TABLE_STYLE_TEMPLATE,
274
+ max_values: int = 20,
275
+ sort_by: Optional[str] = None,
276
+ ascending: bool = False,
277
+ ax: Optional[Axes] = None,
278
+ ) -> Axes:
279
+ """Plot a table of the DataFrame's data on a Matplotlib axes.
280
+
281
+ Parameters
282
+ ----------
283
+ cols : list[str]
284
+ List of columns to include in the table.
285
+ title : str, optional
286
+ Table title.
287
+ style : StyleTemplate, optional
288
+ Styling template. The default is `TABLE_STYLE_TEMPLATE`.
289
+ max_values : int, optional
290
+ Maximum number of rows to display. The default is 20.
291
+ sort_by : str, optional
292
+ Column to sort by.
293
+ ascending : bool, optional
294
+ Sort order. The default is `False`.
295
+ ax : Axes, optional
296
+ Matplotlib axes to plot on. If None, uses the current axes.
297
+
298
+ Returns
299
+ -------
300
+ Axes
301
+ The Matplotlib axes object with the table.
302
+ """
303
+ return aplot_table(
304
+ pd_df=self._obj,
305
+ cols=cols,
306
+ title=title,
307
+ style=style,
308
+ max_values=max_values,
309
+ sort_by=sort_by,
310
+ ascending=ascending,
311
+ ax=ax,
312
+ )
313
+
314
+ def fplot_table(
315
+ self,
316
+ cols: List[str],
317
+ title: Optional[str] = None,
318
+ style: StyleTemplate = TABLE_STYLE_TEMPLATE,
319
+ max_values: int = 20,
320
+ sort_by: Optional[str] = None,
321
+ ascending: bool = False,
322
+ figsize: Tuple[float, float] = (19.2, 10.8),
323
+ ) -> Figure:
324
+ """Plot a table of the DataFrame's data on a new figure.
325
+
326
+ Parameters
327
+ ----------
328
+ cols : list[str]
329
+ List of columns to include in the table.
330
+ title : str, optional
331
+ Table title.
332
+ style : StyleTemplate, optional
333
+ Styling template. The default is `TABLE_STYLE_TEMPLATE`.
334
+ max_values : int, optional
335
+ Maximum number of rows to display. The default is 20.
336
+ sort_by : str, optional
337
+ Column to sort by.
338
+ ascending : bool, optional
339
+ Sort order. The default is `False`.
340
+ figsize : tuple[float, float], optional
341
+ Figure size. The default is (19.2, 10.8).
342
+
343
+ Returns
344
+ -------
345
+ Figure
346
+ The new Matplotlib figure with the table.
347
+ """
348
+ return fplot_table(
349
+ pd_df=self._obj,
350
+ cols=cols,
351
+ title=title,
352
+ style=style,
353
+ max_values=max_values,
354
+ sort_by=sort_by,
355
+ ascending=ascending,
356
+ figsize=figsize,
357
+ )
358
+
359
+ def aplot_timeserie(
360
+ self,
361
+ label: str,
362
+ x: str,
363
+ y: str,
364
+ title: Optional[str] = None,
365
+ style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
366
+ max_values: int = 100,
367
+ sort_by: Optional[str] = None,
368
+ ascending: bool = False,
369
+ std: bool = False,
370
+ ax: Optional[Axes] = None,
371
+ ) -> Axes:
372
+ """Plot a time series on a Matplotlib axes.
373
+
374
+ Parameters
375
+ ----------
376
+ label : str
377
+ Column to use for the series label.
378
+ x : str
379
+ Column to use for the x-axis (time).
380
+ y : str
381
+ Column to use for the y-axis (values).
382
+ title : str, optional
383
+ Chart title.
384
+ style : StyleTemplate, optional
385
+ Styling template. The default is `TIMESERIE_STYLE_TEMPLATE`.
386
+ max_values : int, optional
387
+ Maximum number of data points to plot. The default is 100.
388
+ sort_by : str, optional
389
+ Column to sort by.
390
+ ascending : bool, optional
391
+ Sort order. The default is `False`.
392
+ std : bool, optional
393
+ If True, plot the standard deviation. The default is `False`.
394
+ ax : Axes, optional
395
+ Matplotlib axes to plot on. If None, uses the current axes.
396
+
397
+ Returns
398
+ -------
399
+ Axes
400
+ The Matplotlib axes object with the plot.
401
+ """
402
+ return aplot_timeserie(
403
+ pd_df=self._obj,
404
+ label=label,
405
+ x=x,
406
+ y=y,
407
+ title=title,
408
+ style=style,
409
+ max_values=max_values,
410
+ sort_by=sort_by,
411
+ ascending=ascending,
412
+ std=std,
413
+ ax=ax,
414
+ )
415
+
416
+ def fplot_timeserie(
417
+ self,
418
+ label: str,
419
+ x: str,
420
+ y: str,
421
+ title: Optional[str] = None,
422
+ style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
423
+ max_values: int = 100,
424
+ sort_by: Optional[str] = None,
425
+ ascending: bool = False,
426
+ std: bool = False,
427
+ figsize: Tuple[float, float] = (19.2, 10.8),
428
+ ) -> Figure:
429
+ """Plot a time series on a new figure.
430
+
431
+ Parameters
432
+ ----------
433
+ label : str
434
+ Column to use for the series label.
435
+ x : str
436
+ Column to use for the x-axis (time).
437
+ y : str
438
+ Column to use for the y-axis (values).
439
+ title : str, optional
440
+ Chart title.
441
+ style : StyleTemplate, optional
442
+ Styling template. The default is `TIMESERIE_STYLE_TEMPLATE`.
443
+ max_values : int, optional
444
+ Maximum number of data points to plot. The default is 100.
445
+ sort_by : str, optional
446
+ Column to sort by.
447
+ ascending : bool, optional
448
+ Sort order. The default is `False`.
449
+ std : bool, optional
450
+ If True, plot the standard deviation. The default is `False`.
451
+ figsize : tuple[float, float], optional
452
+ Figure size. The default is (19.2, 10.8).
453
+
454
+ Returns
455
+ -------
456
+ Figure
457
+ The new Matplotlib figure with the plot.
458
+ """
459
+ return fplot_timeserie(
460
+ pd_df=self._obj,
461
+ label=label,
462
+ x=x,
463
+ y=y,
464
+ title=title,
465
+ style=style,
466
+ max_values=max_values,
467
+ sort_by=sort_by,
468
+ ascending=ascending,
469
+ std=std,
470
+ figsize=figsize,
471
+ )
472
+
473
+ def aplot_wordcloud(
474
+ self,
475
+ text_column: str,
476
+ weight_column: Optional[str] = None,
477
+ title: Optional[str] = None,
478
+ style: StyleTemplate = WORDCLOUD_STYLE_TEMPLATE,
479
+ max_words: int = 50,
480
+ stopwords: Optional[List[str]] = None,
481
+ random_state: Optional[int] = None,
482
+ ax: Optional[Axes] = None,
483
+ ) -> Axes:
484
+ """Plot a word cloud on a Matplotlib axes.
485
+
486
+ Parameters
487
+ ----------
488
+ text_column : str
489
+ Column containing words or phrases.
490
+ weight_column : str, optional
491
+ Column containing numeric weights. The default is ``None`` for equal weights.
492
+ title : str, optional
493
+ Chart title.
494
+ style : StyleTemplate, optional
495
+ Styling template. The default is `WORDCLOUD_STYLE_TEMPLATE`.
496
+ max_words : int, optional
497
+ Maximum number of words to display. The default is 50.
498
+ stopwords : list[str], optional
499
+ Words to exclude from the visualization. The default is ``None``.
500
+ random_state : int, optional
501
+ Seed for word placement. The default is ``None``.
502
+ ax : Axes, optional
503
+ Matplotlib axes to plot on. If None, uses the current axes.
504
+
505
+ Returns
506
+ -------
507
+ Axes
508
+ The Matplotlib axes object with the plot.
509
+ """
510
+ return aplot_wordcloud(
511
+ pd_df=self._obj,
512
+ text_column=text_column,
513
+ weight_column=weight_column,
514
+ title=title,
515
+ style=style,
516
+ max_words=max_words,
517
+ stopwords=stopwords,
518
+ random_state=random_state,
519
+ ax=ax,
520
+ )
521
+
522
+ def fplot_wordcloud(
523
+ self,
524
+ text_column: str,
525
+ weight_column: Optional[str] = None,
526
+ title: Optional[str] = None,
527
+ style: StyleTemplate = WORDCLOUD_STYLE_TEMPLATE,
528
+ max_words: int = 50,
529
+ stopwords: Optional[List[str]] = None,
530
+ random_state: Optional[int] = None,
531
+ figsize: Tuple[float, float] = (19.2, 10.8),
532
+ ) -> Figure:
533
+ """Plot a word cloud on a new figure.
534
+
535
+ Parameters
536
+ ----------
537
+ text_column : str
538
+ Column containing words or phrases.
539
+ weight_column : str, optional
540
+ Column containing numeric weights. The default is ``None`` for equal weights.
541
+ title : str, optional
542
+ Chart title.
543
+ style : StyleTemplate, optional
544
+ Styling template. The default is `WORDCLOUD_STYLE_TEMPLATE`.
545
+ max_words : int, optional
546
+ Maximum number of words to display. The default is 50.
547
+ stopwords : list[str], optional
548
+ Words to exclude from the visualization. The default is ``None``.
549
+ random_state : int, optional
550
+ Seed for word placement. The default is ``None``.
551
+ figsize : tuple[float, float], optional
552
+ Figure size. The default is (19.2, 10.8).
553
+
554
+ Returns
555
+ -------
556
+ Figure
557
+ The new Matplotlib figure with the plot.
558
+ """
559
+ return fplot_wordcloud(
560
+ pd_df=self._obj,
561
+ text_column=text_column,
562
+ weight_column=weight_column,
563
+ title=title,
564
+ style=style,
565
+ max_words=max_words,
566
+ stopwords=stopwords,
567
+ random_state=random_state,
568
+ figsize=figsize,
569
+ )
570
+
571
+ def aplot_network(
572
+ self,
573
+ source: str = "source",
574
+ target: str = "target",
575
+ weight: str = "weight",
576
+ title: Optional[str] = None,
577
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
578
+ sort_by: Optional[str] = None,
579
+ ascending: bool = False,
580
+ node_list: Optional[List] = None,
581
+ ax: Optional[Axes] = None,
582
+ ) -> Axes:
583
+ """Plot a network graph on a Matplotlib axes.
584
+
585
+ Parameters
586
+ ----------
587
+ source : str, optional
588
+ Column for source nodes. The default is "source".
589
+ target : str, optional
590
+ Column for target nodes. The default is "target".
591
+ weight : str, optional
592
+ Column for edge weights. The default is "weight".
593
+ title : str, optional
594
+ Chart title.
595
+ style : StyleTemplate, optional
596
+ Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
597
+ sort_by : str, optional
598
+ Column to sort by.
599
+ ascending : bool, optional
600
+ Sort order. The default is `False`.
601
+ node_list : list, optional
602
+ List of nodes to include. If None, all nodes are used.
603
+ ax : Axes, optional
604
+ Matplotlib axes to plot on. If None, uses the current axes.
605
+
606
+ Returns
607
+ -------
608
+ Axes
609
+ The Matplotlib axes object with the plot.
610
+ """
611
+ return aplot_network(
612
+ pd_df=self._obj,
613
+ source=source,
614
+ target=target,
615
+ weight=weight,
616
+ title=title,
617
+ style=style,
618
+ sort_by=sort_by,
619
+ ascending=ascending,
620
+ node_list=node_list,
621
+ ax=ax,
622
+ )
623
+
624
+ def aplot_network_components(
625
+ self,
626
+ source: str = "source",
627
+ target: str = "target",
628
+ weight: str = "weight",
629
+ title: Optional[str] = None,
630
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
631
+ sort_by: Optional[str] = None,
632
+ ascending: bool = False,
633
+ node_list: Optional[List] = None,
634
+ axes: Optional[np.ndarray] = None,
635
+ ) -> None:
636
+ """Plot connected components of a network graph on multiple axes.
637
+
638
+ Parameters
639
+ ----------
640
+ source : str, optional
641
+ Column for source nodes. The default is "source".
642
+ target : str, optional
643
+ Column for target nodes. The default is "target".
644
+ weight : str, optional
645
+ Column for edge weights. The default is "weight".
646
+ title : str, optional
647
+ Chart title.
648
+ style : StyleTemplate, optional
649
+ Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
650
+ sort_by : str, optional
651
+ Column to sort by.
652
+ ascending : bool, optional
653
+ Sort order. The default is `False`.
654
+ node_list : list, optional
655
+ List of nodes to include. If None, all nodes are used.
656
+ axes : np.ndarray, optional
657
+ Numpy array of Matplotlib axes to plot on. If None, new axes are created.
658
+ """
659
+ aplot_network_components(
660
+ pd_df=self._obj,
661
+ source=source,
662
+ target=target,
663
+ weight=weight,
664
+ title=title,
665
+ style=style,
666
+ sort_by=sort_by,
667
+ ascending=ascending,
668
+ node_list=node_list,
669
+ axes=axes,
670
+ )
671
+
672
+ def fplot_network(
673
+ self,
674
+ source: str = "source",
675
+ target: str = "target",
676
+ weight: str = "weight",
677
+ title: Optional[str] = None,
678
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
679
+ sort_by: Optional[str] = None,
680
+ ascending: bool = False,
681
+ node_list: Optional[List] = None,
682
+ figsize: Tuple[float, float] = (19.2, 10.8),
683
+ ) -> Figure:
684
+ """Plot a network graph on a new figure.
685
+
686
+ Parameters
687
+ ----------
688
+ source : str, optional
689
+ Column for source nodes. The default is "source".
690
+ target : str, optional
691
+ Column for target nodes. The default is "target".
692
+ weight : str, optional
693
+ Column for edge weights. The default is "weight".
694
+ title : str, optional
695
+ Chart title.
696
+ style : StyleTemplate, optional
697
+ Styling template. The default is `NETWORK_STYLE_TEMPLATE`.
698
+ sort_by : str, optional
699
+ Column to sort by.
700
+ ascending : bool, optional
701
+ Sort order. The default is `False`.
702
+ node_list : list, optional
703
+ List of nodes to include. If None, all nodes are used.
704
+ figsize : tuple[float, float], optional
705
+ Figure size. The default is (19.2, 10.8).
706
+
707
+ Returns
708
+ -------
709
+ Figure
710
+ The new Matplotlib figure with the plot.
711
+ """
712
+ return fplot_network(
713
+ pd_df=self._obj,
714
+ source=source,
715
+ target=target,
716
+ weight=weight,
717
+ title=title,
718
+ style=style,
719
+ sort_by=sort_by,
720
+ ascending=ascending,
721
+ node_list=node_list,
722
+ )
723
+
724
+ def fplot_treemap(
725
+ self,
726
+ path: str,
727
+ values: str,
728
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
729
+ title: Optional[str] = None,
730
+ color: Optional[str] = None,
731
+ sort_by: Optional[str] = None,
732
+ max_values: int = 100,
733
+ ascending: bool = False,
734
+ fig: Optional[go.Figure] = None,
735
+ ) -> go.Figure:
736
+ """Plot a treemap on a new Plotly figure.
737
+
738
+ Parameters
739
+ ----------
740
+ path : str
741
+ Column representing the hierarchy path.
742
+ values : str
743
+ Column with values for the treemap areas.
744
+ style : StyleTemplate, optional
745
+ Styling template. The default is `TREEMAP_STYLE_TEMPLATE`.
746
+ title : str, optional
747
+ Chart title.
748
+ color : str, optional
749
+ Column to use for color coding.
750
+ sort_by : str, optional
751
+ Column to sort by.
752
+ max_values : int, optional
753
+ Maximum number of items to display. The default is 100.
754
+ ascending : bool, optional
755
+ Sort order. The default is `False`.
756
+ fig : go.Figure, optional
757
+ Existing Plotly figure to add to. If None, a new figure is created.
758
+
759
+ Returns
760
+ -------
761
+ go.Figure
762
+ The Plotly figure with the treemap.
763
+ """
764
+ return fplot_treemap(
765
+ pd_df=self._obj,
766
+ path=path,
767
+ values=values,
768
+ title=title,
769
+ style=style,
770
+ color=color,
771
+ sort_by=sort_by,
772
+ ascending=ascending,
773
+ max_values=max_values,
774
+ fig=fig,
775
+ )
776
+
777
+ def fplot_composite_treemap(
778
+ self,
779
+ paths: List[str],
780
+ values: str,
781
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
782
+ title: Optional[str] = None,
783
+ color: Optional[str] = None,
784
+ sort_by: Optional[str] = None,
785
+ max_values: int = 100,
786
+ ascending: bool = False,
787
+ fig: Optional[go.Figure] = None,
788
+ ) -> Optional[go.Figure]:
789
+ """Plot a composite treemap on a new Plotly figure.
790
+
791
+ Parameters
792
+ ----------
793
+ paths : list[str]
794
+ Columns representing the hierarchy paths for each treemap.
795
+ values : str
796
+ Column with values for the treemap areas.
797
+ style : StyleTemplate, optional
798
+ Styling template. The default is `TREEMAP_STYLE_TEMPLATE`.
799
+ title : str, optional
800
+ Chart title.
801
+ color : str, optional
802
+ Column to use for color coding.
803
+ sort_by : str, optional
804
+ Column to sort by.
805
+ max_values : int, optional
806
+ Maximum number of items to display. The default is 100.
807
+ ascending : bool, optional
808
+ Sort order. The default is `False`.
809
+ fig : go.Figure, optional
810
+ Existing Plotly figure to add to. If None, a new figure is created.
811
+
812
+ Returns
813
+ -------
814
+ go.Figure, optional
815
+ The Plotly figure with the composite treemap, or None if the input data is empty.
816
+ """
817
+ pd_dfs: Dict[str, pd.DataFrame] = {}
818
+ for path in paths:
819
+ pd_dfs[path] = self._obj
820
+
821
+ return plot_composite_treemap(
822
+ pd_dfs=pd_dfs,
823
+ values=values,
824
+ title=title,
825
+ style=style,
826
+ color=color,
827
+ sort_by=sort_by,
828
+ ascending=ascending,
829
+ max_values=max_values,
830
+ )
831
+
832
+
833
+ __all__ = [
834
+ "DataFrameAccessor",
835
+ "StyleTemplate",
836
+ "aplot_bubble",
837
+ "aplot_network",
838
+ "aplot_network_components",
839
+ "aplot_table",
840
+ "aplot_timeserie",
841
+ "aplot_wordcloud",
842
+ "fplot_bubble",
843
+ "fplot_network",
844
+ "fplot_table",
845
+ "fplot_timeserie",
846
+ "fplot_wordcloud",
847
+ "fplot_treemap",
848
+ "plot_composite_bubble",
849
+ "plot_composite_treemap",
850
+ ]