MatplotLibAPI 3.2.13__tar.gz → 3.2.14__tar.gz

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.
Files changed (39) hide show
  1. matplotlibapi-3.2.14/.coverage +0 -0
  2. matplotlibapi-3.2.14/.github/workflows/ci.yml +43 -0
  3. matplotlibapi-3.2.14/.github/workflows/python-publish.yml +39 -0
  4. matplotlibapi-3.2.14/.gitignore +18 -0
  5. matplotlibapi-3.2.14/AGENTS.md +81 -0
  6. matplotlibapi-3.2.14/MatplotLibAPI/Bubble.py +453 -0
  7. matplotlibapi-3.2.14/MatplotLibAPI/Composite.py +195 -0
  8. matplotlibapi-3.2.14/MatplotLibAPI/Network.py +884 -0
  9. matplotlibapi-3.2.14/MatplotLibAPI/Pivot.py +134 -0
  10. matplotlibapi-3.2.14/MatplotLibAPI/StyleTemplate.py +309 -0
  11. matplotlibapi-3.2.14/MatplotLibAPI/Table.py +220 -0
  12. matplotlibapi-3.2.14/MatplotLibAPI/Timeserie.py +342 -0
  13. matplotlibapi-3.2.14/MatplotLibAPI/Treemap.py +165 -0
  14. matplotlibapi-3.2.14/MatplotLibAPI/Wordcloud.py +314 -0
  15. matplotlibapi-3.2.14/MatplotLibAPI/__init__.py +850 -0
  16. {matplotlibapi-3.2.13/MatplotLibAPI.egg-info → matplotlibapi-3.2.14}/PKG-INFO +16 -9
  17. matplotlibapi-3.2.14/SECURITY.md +21 -0
  18. matplotlibapi-3.2.14/pyproject.toml +32 -0
  19. matplotlibapi-3.2.14/tests/__init__.py +0 -0
  20. matplotlibapi-3.2.14/tests/test_plots.py +126 -0
  21. matplotlibapi-3.2.14/tests/test_smoke.py +67 -0
  22. matplotlibapi-3.2.13/MatplotLibAPI/Bubble.py +0 -176
  23. matplotlibapi-3.2.13/MatplotLibAPI/Composite.py +0 -196
  24. matplotlibapi-3.2.13/MatplotLibAPI/Network.py +0 -468
  25. matplotlibapi-3.2.13/MatplotLibAPI/Pivot.py +0 -213
  26. matplotlibapi-3.2.13/MatplotLibAPI/StyleTemplate.py +0 -368
  27. matplotlibapi-3.2.13/MatplotLibAPI/Table.py +0 -91
  28. matplotlibapi-3.2.13/MatplotLibAPI/Timeserie.py +0 -128
  29. matplotlibapi-3.2.13/MatplotLibAPI/Treemap.py +0 -107
  30. matplotlibapi-3.2.13/MatplotLibAPI/__init__.py +0 -325
  31. matplotlibapi-3.2.13/MatplotLibAPI.egg-info/SOURCES.txt +0 -17
  32. matplotlibapi-3.2.13/MatplotLibAPI.egg-info/dependency_links.txt +0 -1
  33. matplotlibapi-3.2.13/MatplotLibAPI.egg-info/requires.txt +0 -8
  34. matplotlibapi-3.2.13/MatplotLibAPI.egg-info/top_level.txt +0 -1
  35. matplotlibapi-3.2.13/PKG-INFO +0 -24
  36. matplotlibapi-3.2.13/pyproject.toml +0 -11
  37. matplotlibapi-3.2.13/setup.cfg +0 -4
  38. {matplotlibapi-3.2.13 → matplotlibapi-3.2.14}/LICENSE +0 -0
  39. {matplotlibapi-3.2.13 → matplotlibapi-3.2.14}/README.md +0 -0
Binary file
@@ -0,0 +1,43 @@
1
+ name: Python CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+
22
+ - name: Set up Python ${{ matrix.python-version }}
23
+ uses: actions/setup-python@v4
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+
27
+ - name: Install dependencies
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install -e .[dev]
31
+
32
+ - name: Run style checks
33
+ run: |
34
+ pydocstyle MatplotLibAPI
35
+ black --check .
36
+
37
+ - name: Run static type analysis
38
+ run: |
39
+ pyright MatplotLibAPI
40
+
41
+ - name: Run tests with coverage
42
+ run: |
43
+ pytest -q --cov=MatplotLibAPI --cov-report=term-missing --cov-fail-under=70
@@ -0,0 +1,39 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ deploy:
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v3
27
+ with:
28
+ python-version: '3.x'
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install build
33
+ - name: Build package
34
+ run: python -m build
35
+ - name: Publish package
36
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37
+ with:
38
+ user: __token__
39
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,18 @@
1
+ .DS_Store
2
+ .vscode
3
+ .env
4
+ .pytest_cache
5
+ .benchmarks
6
+ scratch*
7
+ data/
8
+ # Python build artifacts
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+
13
+ # Python cache files
14
+ __pycache__/
15
+ *.py[cod]
16
+
17
+ # Virtual environments
18
+ .venv/
@@ -0,0 +1,81 @@
1
+ # AGENTS.md
2
+
3
+ These instructions apply to any automated agent contributing to this repository.
4
+
5
+ ## 1. Code Style
6
+
7
+ - Use standard PEP 8 formatting for all Python code.
8
+ - Write commit messages in the imperative mood (e.g., "Add feature" not "Added feature").
9
+ - Keep the implementation Pythonic and maintainable.
10
+
11
+ ## 2. Docstring Style
12
+
13
+ - Document all public classes, parameters, methods, and functions.
14
+ - Use **NumPy-style** docstrings following [PEP 257](httpshttps://peps.python.org/pep-0257/) conventions.
15
+ - **Do not** use `:param` / `:type` syntax (reST/Sphinx style) or Google-style `Args`.
16
+ - Always include type hints in function signatures.
17
+ - Begin docstrings with a **short, one-line summary**, followed by a blank line and an optional extended description.
18
+ - Use the following NumPy-style sections when applicable:
19
+ - `Parameters`
20
+ - `Returns`
21
+ - `Raises`
22
+ - `Examples`
23
+ - **For classes, the main docstring should include a `Methods` section summarizing each public method and its one-line description.**
24
+ - For optional parameters, note the default value in the description.
25
+ - Use present tense and active voice (“Return…”, “Fetch…”).
26
+
27
+ ## 3. Code Quality and Testing
28
+
29
+ Before running tests, install the development dependencies declared in `pyproject.toml`:
30
+
31
+ ```bash
32
+ pip install -e .[dev]
33
+ ```
34
+
35
+ To ensure your changes will pass the automated checks in our Continuous Integration (CI) pipeline, run the following commands locally before committing. All checks must pass.
36
+
37
+ **Style Checks:**
38
+ ```bash
39
+ pydocstyle MatplotLibAPI
40
+ black --check .
41
+ ```
42
+
43
+ **Static Type Analysis:**
44
+ ```bash
45
+ pyright MatplotLibAPI
46
+ ```
47
+
48
+ **Unit Tests and Coverage:**
49
+ ```bash
50
+ pytest -q --cov=MatplotLibAPI --cov-report=term-missing --cov-fail-under=70
51
+ ```
52
+
53
+ ## 4. Directory Layout
54
+
55
+ - Production code lives in `MatplotLibAPI/`.
56
+ - Tests live in `tests/`.
57
+ - Keep imports relative within the package (e.g., `from MatplotLibAPI...`).
58
+
59
+ ## 5. Pull Request Messages
60
+
61
+ Each pull request should include:
62
+
63
+ 1. **Summary** – brief description of the change.
64
+ 2. **Testing** – commands run and confirmation that the tests passed.
65
+
66
+ Example PR body:
67
+
68
+ ```
69
+ ### Summary
70
+ - add new helper to utils.list
71
+ - expand tests for list chunking
72
+
73
+ ### Testing
74
+ - `pytest` (all tests passed)
75
+ ```
76
+
77
+ ## 6. General Guidelines
78
+
79
+ - Avoid pushing large data files to the repository.
80
+ - Prefer small, focused commits over sweeping changes.
81
+ - Update or add tests whenever you modify functionality.
@@ -0,0 +1,453 @@
1
+ """Bubble chart plotting helpers.
2
+
3
+ Provides functions to create and render bubble charts using seaborn and matplotlib,
4
+ with customizable styling via `StyleTemplate`.
5
+ """
6
+
7
+ from typing import Dict, Optional, Tuple, cast
8
+
9
+ import matplotlib.pyplot as plt
10
+ import pandas as pd
11
+ import seaborn as sns
12
+ from matplotlib.axes import Axes
13
+ from matplotlib.figure import Figure
14
+ from matplotlib.ticker import NullLocator
15
+
16
+ from .StyleTemplate import (
17
+ BUBBLE_STYLE_TEMPLATE,
18
+ MAX_RESULTS,
19
+ StyleTemplate,
20
+ bmk_formatter,
21
+ format_func,
22
+ generate_ticks,
23
+ percent_formatter,
24
+ string_formatter,
25
+ validate_dataframe,
26
+ DynamicFuncFormatter,
27
+ FormatterFunc,
28
+ )
29
+
30
+
31
+ def _prepare_bubble_data(
32
+ pd_df: pd.DataFrame,
33
+ label: str,
34
+ x: str,
35
+ y: str,
36
+ z: str,
37
+ sort_by: Optional[str],
38
+ ascending: bool,
39
+ max_values: int,
40
+ center_to_mean: bool,
41
+ style: StyleTemplate,
42
+ ) -> pd.DataFrame:
43
+ """Prepare data for bubble chart.
44
+
45
+ Parameters
46
+ ----------
47
+ pd_df : pd.DataFrame
48
+ Input DataFrame.
49
+ label : str
50
+ Column name for bubble labels.
51
+ x : str
52
+ Column name for x-axis values.
53
+ y : str
54
+ Column name for y-axis values.
55
+ z : str
56
+ Column name for bubble sizes.
57
+ sort_by : Optional[str]
58
+ Column to sort by.
59
+ ascending : bool
60
+ Sort order.
61
+ max_values : int
62
+ Maximum number of bubbles to display.
63
+ center_to_mean : bool
64
+ Whether to center x-axis values around the mean.
65
+ style : StyleTemplate
66
+ Styling for the plot.
67
+
68
+ Returns
69
+ -------
70
+ pd.DataFrame
71
+ Prepared DataFrame for plotting.
72
+
73
+ Raises
74
+ ------
75
+ AttributeError
76
+ If required columns are missing from the DataFrame.
77
+ """
78
+ validate_dataframe(pd_df, cols=[label, x, y, z], sort_by=sort_by)
79
+ sort_col = sort_by or z
80
+
81
+ plot_df = (
82
+ pd_df[[label, x, y, z]]
83
+ .sort_values(by=[sort_col], ascending=ascending) # type: ignore
84
+ .head(max_values)
85
+ .copy()
86
+ )
87
+
88
+ if center_to_mean:
89
+ plot_df[x] -= plot_df[x].mean()
90
+
91
+ plot_df["quintile"] = pd.qcut(plot_df[z], 5, labels=False, duplicates="drop")
92
+ plot_df["fontsize"] = plot_df["quintile"].map(style.font_mapping) # type: ignore
93
+ return plot_df
94
+
95
+
96
+ def _setup_bubble_axes(
97
+ ax: Axes,
98
+ style: StyleTemplate,
99
+ pd_df: pd.DataFrame,
100
+ x: str,
101
+ y: str,
102
+ format_funcs: Optional[Dict[str, Optional[FormatterFunc]]],
103
+ ) -> None:
104
+ """Configure axes for the bubble chart.
105
+
106
+ Parameters
107
+ ----------
108
+ ax : Axes
109
+ Matplotlib axes object.
110
+ style : StyleTemplate
111
+ Styling for the plot.
112
+ pd_df : pd.DataFrame
113
+ DataFrame used for plotting.
114
+ x : str
115
+ Column name for x-axis values.
116
+ y : str
117
+ Column name for y-axis values.
118
+ format_funcs : Optional[Dict[str, Optional[FormatterFunc]]]
119
+ Functions to format axis tick labels.
120
+ """
121
+ ax.set_facecolor(style.background_color)
122
+
123
+ if style.xscale:
124
+ ax.set(xscale=style.xscale)
125
+ if style.yscale:
126
+ ax.set(yscale=style.yscale)
127
+
128
+ # X-axis ticks and formatting
129
+ x_min, x_max = cast(float, pd_df[x].min()), cast(float, pd_df[x].max())
130
+ ax.xaxis.set_ticks(generate_ticks(x_min, x_max, num_ticks=style.x_ticks))
131
+ ax.xaxis.grid(True, "major", linewidth=0.5, color=style.font_color)
132
+ if format_funcs and (fmt_x := format_funcs.get(x)):
133
+ ax.xaxis.set_major_formatter(DynamicFuncFormatter(fmt_x))
134
+
135
+ # Y-axis ticks and formatting
136
+ y_min, y_max = cast(float, pd_df[y].min()), cast(float, pd_df[y].max())
137
+ ax.yaxis.set_ticks(generate_ticks(y_min, y_max, num_ticks=style.y_ticks))
138
+ if style.yscale == "log":
139
+ ax.yaxis.set_minor_locator(NullLocator())
140
+ else:
141
+ ax.minorticks_off()
142
+ ax.yaxis.grid(True, "major", linewidth=0.5, color=style.font_color)
143
+ if format_funcs and (fmt_y := format_funcs.get(y)):
144
+ ax.yaxis.set_major_formatter(DynamicFuncFormatter(fmt_y))
145
+
146
+ ax.tick_params(
147
+ axis="both", which="major", colors=style.font_color, labelsize=style.font_size
148
+ )
149
+
150
+
151
+ def _draw_bubbles(
152
+ ax: Axes, plot_df: pd.DataFrame, x: str, y: str, z: str, style: StyleTemplate
153
+ ) -> None:
154
+ """Draw bubbles on the axes.
155
+
156
+ Parameters
157
+ ----------
158
+ ax : Axes
159
+ Matplotlib axes object.
160
+ plot_df : pd.DataFrame
161
+ DataFrame with data for plotting.
162
+ x : str
163
+ Column name for x-axis values.
164
+ y : str
165
+ Column name for y-axis values.
166
+ z : str
167
+ Column name for bubble sizes.
168
+ style : StyleTemplate
169
+ Styling for the plot.
170
+ """
171
+ sns.scatterplot(
172
+ data=plot_df,
173
+ x=x,
174
+ y=y,
175
+ size=z,
176
+ hue="quintile",
177
+ sizes=(100, 2000),
178
+ legend=False,
179
+ palette=sns.color_palette(style.palette, as_cmap=True),
180
+ edgecolor=style.background_color,
181
+ ax=ax,
182
+ )
183
+
184
+
185
+ def _draw_bubble_labels(
186
+ ax: Axes,
187
+ plot_df: pd.DataFrame,
188
+ label: str,
189
+ x: str,
190
+ y: str,
191
+ style: StyleTemplate,
192
+ format_funcs: Optional[Dict[str, Optional[FormatterFunc]]],
193
+ ) -> None:
194
+ """Draw labels for each bubble.
195
+
196
+ Parameters
197
+ ----------
198
+ ax : Axes
199
+ Matplotlib axes object.
200
+ plot_df : pd.DataFrame
201
+ DataFrame with data for plotting.
202
+ label : str
203
+ Column name for bubble labels.
204
+ x : str
205
+ Column name for x-axis values.
206
+ y : str
207
+ Column name for y-axis values.
208
+ style : StyleTemplate
209
+ Styling for the plot.
210
+ format_funcs : Optional[Dict[str, Optional[FormatterFunc]]]
211
+ Functions to format bubble labels.
212
+ """
213
+ for _, row in plot_df.iterrows():
214
+ x_val, y_val, label_val = row[x], row[y], str(row[label])
215
+ if format_funcs and (fmt_label := format_funcs.get(label)):
216
+ label_val = fmt_label(label_val, None)
217
+ ax.text(
218
+ cast(float, x_val),
219
+ cast(float, y_val),
220
+ label_val,
221
+ ha="center",
222
+ fontsize=row["fontsize"],
223
+ color=style.font_color,
224
+ )
225
+
226
+
227
+ def _draw_mean_lines(
228
+ ax: Axes,
229
+ plot_df: pd.DataFrame,
230
+ x: str,
231
+ y: str,
232
+ hline: bool,
233
+ vline: bool,
234
+ style: StyleTemplate,
235
+ ) -> None:
236
+ """Draw horizontal and vertical mean lines.
237
+
238
+ Parameters
239
+ ----------
240
+ ax : Axes
241
+ Matplotlib axes object.
242
+ plot_df : pd.DataFrame
243
+ DataFrame with data for plotting.
244
+ x : str
245
+ Column name for x-axis values.
246
+ y : str
247
+ Column name for y-axis values.
248
+ hline : bool
249
+ Whether to draw a horizontal line at the mean of y.
250
+ vline : bool
251
+ Whether to draw a vertical line at the mean of x.
252
+ style : StyleTemplate
253
+ Styling for the plot.
254
+ """
255
+ if vline:
256
+ ax.axvline(
257
+ int(cast(float, plot_df[x].mean())), linestyle="--", color=style.font_color
258
+ )
259
+ if hline:
260
+ ax.axhline(
261
+ int(cast(float, plot_df[y].mean())), linestyle="--", color=style.font_color
262
+ )
263
+
264
+
265
+ def aplot_bubble(
266
+ pd_df: pd.DataFrame,
267
+ label: str,
268
+ x: str,
269
+ y: str,
270
+ z: str,
271
+ title: Optional[str] = None,
272
+ style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
273
+ max_values: int = MAX_RESULTS,
274
+ center_to_mean: bool = False,
275
+ sort_by: Optional[str] = None,
276
+ ascending: bool = False,
277
+ hline: bool = False,
278
+ vline: bool = False,
279
+ ax: Optional[Axes] = None,
280
+ ) -> Axes:
281
+ """Plot a bubble chart onto the given axes.
282
+
283
+ Parameters
284
+ ----------
285
+ pd_df : pd.DataFrame
286
+ DataFrame containing the data to plot.
287
+ label : str
288
+ Column name used for labeling bubbles.
289
+ x : str
290
+ Column name for x-axis values.
291
+ y : str
292
+ Column name for y-axis values.
293
+ z : str
294
+ Column name for bubble sizes.
295
+ title : str, optional
296
+ Plot title.
297
+ style : StyleTemplate, optional
298
+ Plot styling options. The default is `BUBBLE_STYLE_TEMPLATE`.
299
+ max_values : int, optional
300
+ Max number of rows to display. The default is `MAX_RESULTS`.
301
+ center_to_mean : bool, optional
302
+ Whether to center x values around their mean. The default is `False`.
303
+ sort_by : str, optional
304
+ Column to sort by before slicing.
305
+ ascending : bool, optional
306
+ Sort order. The default is `False`.
307
+ hline : bool, optional
308
+ Whether to draw a horizontal line at the mean of y. The default is `False`.
309
+ vline : bool, optional
310
+ Whether to draw a vertical line at the mean of x. The default is `False`.
311
+ ax : Axes, optional
312
+ Existing matplotlib axes to use. If None, uses current axes.
313
+
314
+ Returns
315
+ -------
316
+ Axes
317
+ The matplotlib Axes object containing the bubble chart.
318
+
319
+ Raises
320
+ ------
321
+ AttributeError
322
+ If required columns are not in the DataFrame.
323
+
324
+ Examples
325
+ --------
326
+ >>> import pandas as pd
327
+ >>> import matplotlib.pyplot as plt
328
+ >>> from MatplotLibAPI.Bubble import aplot_bubble
329
+ >>> data = {
330
+ ... 'country': ['A', 'B', 'C', 'D'],
331
+ ... 'gdp_per_capita': [45000, 42000, 52000, 48000],
332
+ ... 'life_expectancy': [81, 78, 83, 82],
333
+ ... 'population': [10, 20, 5, 30]
334
+ ... }
335
+ >>> df = pd.DataFrame(data)
336
+ >>> fig, ax = plt.subplots()
337
+ >>> aplot_bubble(df, label='country', x='gdp_per_capita', y='life_expectancy', z='population', ax=ax)
338
+ """
339
+ if ax is None:
340
+ ax = cast(Axes, plt.gca())
341
+
342
+ plot_df = _prepare_bubble_data(
343
+ pd_df, label, x, y, z, sort_by, ascending, max_values, center_to_mean, style
344
+ )
345
+
346
+ format_funcs = format_func(style.format_funcs, label=label, x=x, y=y, z=z)
347
+
348
+ _setup_bubble_axes(ax, style, plot_df, x, y, format_funcs)
349
+
350
+ _draw_bubbles(ax, plot_df, x, y, z, style)
351
+
352
+ _draw_mean_lines(ax, plot_df, x, y, hline, vline, style)
353
+
354
+ _draw_bubble_labels(ax, plot_df, label, x, y, style, format_funcs)
355
+
356
+ if title:
357
+ ax.set_title(title, color=style.font_color, fontsize=style.font_size * 2)
358
+
359
+ return ax
360
+
361
+
362
+ def fplot_bubble(
363
+ pd_df: pd.DataFrame,
364
+ label: str,
365
+ x: str,
366
+ y: str,
367
+ z: str,
368
+ title: Optional[str] = None,
369
+ style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
370
+ max_values: int = MAX_RESULTS,
371
+ center_to_mean: bool = False,
372
+ sort_by: Optional[str] = None,
373
+ ascending: bool = False,
374
+ hline: bool = False,
375
+ vline: bool = False,
376
+ figsize: Tuple[float, float] = (19.2, 10.8),
377
+ ) -> Figure:
378
+ """Create a new matplotlib Figure with a bubble chart.
379
+
380
+ Parameters
381
+ ----------
382
+ pd_df : pd.DataFrame
383
+ DataFrame containing the data to plot.
384
+ label : str
385
+ Column name for bubble labels.
386
+ x : str
387
+ Column name for x-axis values.
388
+ y : str
389
+ Column name for y-axis values.
390
+ z : str
391
+ Column name for bubble sizes.
392
+ title : str, optional
393
+ Title for the chart. The default is ``None``.
394
+ style : StyleTemplate, optional
395
+ Plot styling. The default is `BUBBLE_STYLE_TEMPLATE`.
396
+ max_values : int, optional
397
+ Max number of rows to display. The default is `MAX_RESULTS`.
398
+ center_to_mean : bool, optional
399
+ Whether to center x around its mean. The default is `False`.
400
+ sort_by : str, optional
401
+ Column to sort by.
402
+ ascending : bool, optional
403
+ Sort order. The default is `False`.
404
+ hline : bool, optional
405
+ Draw horizontal line at mean y. The default is `False`.
406
+ vline : bool, optional
407
+ Draw vertical line at mean x. The default is `False`.
408
+ figsize : tuple[float, float], optional
409
+ Size of the figure. The default is (19.2, 10.8).
410
+
411
+ Returns
412
+ -------
413
+ Figure
414
+ A matplotlib Figure object containing the bubble chart.
415
+
416
+ Raises
417
+ ------
418
+ AttributeError
419
+ If required columns are not in the DataFrame.
420
+
421
+ Examples
422
+ --------
423
+ >>> import pandas as pd
424
+ >>> from MatplotLibAPI.Bubble import fplot_bubble
425
+ >>> data = {
426
+ ... 'country': ['A', 'B', 'C', 'D'],
427
+ ... 'gdp_per_capita': [45000, 42000, 52000, 48000],
428
+ ... 'life_expectancy': [81, 78, 83, 82],
429
+ ... 'population': [10, 20, 5, 30]
430
+ ... }
431
+ >>> df = pd.DataFrame(data)
432
+ >>> fig = fplot_bubble(df, label='country', x='gdp_per_capita', y='life_expectancy', z='population')
433
+ """
434
+ fig = cast(Figure, plt.figure(figsize=figsize))
435
+ fig.patch.set_facecolor(style.background_color)
436
+ ax = fig.add_subplot()
437
+ aplot_bubble(
438
+ pd_df=pd_df,
439
+ label=label,
440
+ x=x,
441
+ y=y,
442
+ z=z,
443
+ title=title,
444
+ style=style,
445
+ max_values=max_values,
446
+ center_to_mean=center_to_mean,
447
+ sort_by=sort_by,
448
+ ascending=ascending,
449
+ hline=hline,
450
+ vline=vline,
451
+ ax=ax,
452
+ )
453
+ return fig