MatplotLibAPI 3.2.21__tar.gz → 3.3.0__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 (57) hide show
  1. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/AGENTS.md +1 -1
  2. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Bubble.py +6 -4
  3. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Composite.py +76 -42
  4. matplotlibapi-3.3.0/MatplotLibAPI/Network.py +1823 -0
  5. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/StyleTemplate.py +19 -18
  6. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Table.py +12 -2
  7. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Wordcloud.py +55 -38
  8. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/__init__.py +4 -4
  9. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/accessor.py +304 -78
  10. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/PKG-INFO +1 -1
  11. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/pyproject.toml +1 -1
  12. matplotlibapi-3.3.0/tests/test_composite.py +78 -0
  13. matplotlibapi-3.3.0/tests/test_network.py +188 -0
  14. matplotlibapi-3.3.0/tests/test_style_template.py +27 -0
  15. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_wordcloud.py +3 -3
  16. matplotlibapi-3.2.21/MatplotLibAPI/Network.py +0 -989
  17. matplotlibapi-3.2.21/tests/test_network.py +0 -29
  18. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/.github/workflows/ci.yml +0 -0
  19. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/.github/workflows/python-publish.yml +0 -0
  20. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/.gitignore +0 -0
  21. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/LICENSE +0 -0
  22. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Area.py +0 -0
  23. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Bar.py +0 -0
  24. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/BoxViolin.py +0 -0
  25. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Heatmap.py +0 -0
  26. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Histogram.py +0 -0
  27. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Pie.py +0 -0
  28. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Pivot.py +0 -0
  29. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Sankey.py +0 -0
  30. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Sunburst.py +0 -0
  31. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Timeserie.py +0 -0
  32. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Treemap.py +0 -0
  33. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/Waffle.py +0 -0
  34. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/_typing.py +0 -0
  35. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/MatplotLibAPI/_visualization_utils.py +0 -0
  36. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/README.md +0 -0
  37. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/SECURITY.md +0 -0
  38. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/SUGGESTIONS.md +0 -0
  39. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/scripts/generate_sample_data.py +0 -0
  40. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/__init__.py +0 -0
  41. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/conftest.py +0 -0
  42. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_area.py +0 -0
  43. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_bar.py +0 -0
  44. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_box_violin.py +0 -0
  45. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_bubble.py +0 -0
  46. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_dependencies.py +0 -0
  47. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_heatmap.py +0 -0
  48. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_histogram.py +0 -0
  49. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_pie.py +0 -0
  50. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_pivot.py +0 -0
  51. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_sankey.py +0 -0
  52. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_smoke.py +0 -0
  53. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_sunburst.py +0 -0
  54. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_table.py +0 -0
  55. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_timeseries.py +0 -0
  56. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_treemap.py +0 -0
  57. {matplotlibapi-3.2.21 → matplotlibapi-3.3.0}/tests/test_waffle.py +0 -0
@@ -60,7 +60,7 @@ pytest -q --cov=MatplotLibAPI --cov-report=term-missing --cov-fail-under=70
60
60
 
61
61
  Each pull request should include:
62
62
 
63
- 1. **Summary** – brief description of the change.
63
+ 1. **Summary** – brief description of the change. Mention breaking changes.
64
64
  2. **Testing** – commands run and confirmation that the tests passed.
65
65
 
66
66
  Example PR body:
@@ -17,12 +17,10 @@ from .StyleTemplate import (
17
17
  BUBBLE_STYLE_TEMPLATE,
18
18
  FIG_SIZE,
19
19
  MAX_RESULTS,
20
+ TITLE_SCALE_FACTOR,
20
21
  StyleTemplate,
21
- bmk_formatter,
22
22
  format_func,
23
23
  generate_ticks,
24
- percent_formatter,
25
- string_formatter,
26
24
  validate_dataframe,
27
25
  DynamicFuncFormatter,
28
26
  FormatterFunc,
@@ -355,7 +353,11 @@ def aplot_bubble(
355
353
  _draw_bubble_labels(ax, plot_df, label, x, y, style, format_funcs)
356
354
 
357
355
  if title:
358
- ax.set_title(title, color=style.font_color, fontsize=style.font_size * 2)
356
+ ax.set_title(
357
+ title,
358
+ color=style.font_color,
359
+ fontsize=style.font_size * TITLE_SCALE_FACTOR,
360
+ )
359
361
 
360
362
  return ax
361
363
 
@@ -5,13 +5,19 @@ from typing import Dict, Iterable, Optional, Tuple, cast
5
5
  import matplotlib.pyplot as plt
6
6
  import pandas as pd
7
7
  import plotly.graph_objects as go
8
+ from matplotlib.axes import Axes
8
9
  from matplotlib.figure import Figure
9
10
  from matplotlib.gridspec import GridSpec
10
11
  from plotly.subplots import make_subplots
11
12
 
12
13
  from .Bubble import BUBBLE_STYLE_TEMPLATE, FIG_SIZE, aplot_bubble
13
- from .Network import NETWORK_STYLE_TEMPLATE, aplot_network
14
- from .StyleTemplate import MAX_RESULTS, StyleTemplate, validate_dataframe
14
+ from .Network import aplot_network
15
+ from .StyleTemplate import (
16
+ MAX_RESULTS,
17
+ TITLE_SCALE_FACTOR,
18
+ StyleTemplate,
19
+ validate_dataframe,
20
+ )
15
21
  from .Table import aplot_table
16
22
  from .Treemap import TREEMAP_STYLE_TEMPLATE, aplot_treemap
17
23
  from .Wordcloud import WORDCLOUD_STYLE_TEMPLATE, aplot_wordcloud
@@ -122,7 +128,10 @@ def plot_composite_bubble(
122
128
  max_values=table_rows,
123
129
  style=style,
124
130
  )
125
- fig.tight_layout()
131
+ if title:
132
+ fig.tight_layout(rect=(0, 0, 1, 0.95))
133
+ else:
134
+ fig.tight_layout()
126
135
  return fig
127
136
 
128
137
 
@@ -200,17 +209,17 @@ def plot_composite_treemap(
200
209
  def plot_wordcloud_network(
201
210
  nodes_df: pd.DataFrame,
202
211
  edges_df: pd.DataFrame,
203
- text_column: str = "node",
204
- node_weight: Optional[str] = "weight",
205
- source: str = "source",
206
- target: str = "target",
207
- edge_weight: str = "weight",
208
- wordcloud_title: Optional[str] = None,
209
- network_title: Optional[str] = None,
210
- wordcloud_style: StyleTemplate = WORDCLOUD_STYLE_TEMPLATE,
211
- network_style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
212
+ node_col: str = "node",
213
+ node_weight_col: str = "weight",
214
+ edge_source_col: str = "source",
215
+ edge_target_col: str = "target",
216
+ edge_weight_col: str = "weight",
212
217
  max_words: int = MAX_RESULTS,
213
218
  stopwords: Optional[Iterable[str]] = None,
219
+ title: Optional[str] = None,
220
+ style: StyleTemplate = WORDCLOUD_STYLE_TEMPLATE,
221
+ wordcloud_style: Optional[StyleTemplate] = None,
222
+ network_style: Optional[StyleTemplate] = None,
214
223
  figsize: Tuple[float, float] = FIG_SIZE,
215
224
  ) -> Figure:
216
225
  """Plot a word cloud above a network graph.
@@ -221,31 +230,33 @@ def plot_wordcloud_network(
221
230
  DataFrame containing node labels and optional weights for the word cloud.
222
231
  edges_df : pd.DataFrame
223
232
  DataFrame containing edge connections for the network plot.
224
- text_column : str, optional
233
+ node_col : str, optional
225
234
  Column in ``nodes_df`` containing the node labels. The default is ``"node"``.
226
- node_weight : str, optional
235
+ node_weight_col : str, optional
227
236
  Column in ``nodes_df`` containing weights for sizing words. The default is
228
237
  ``"weight"``.
229
- source : str, optional
238
+ edge_source_col : str, optional
230
239
  Column in ``edges_df`` containing source nodes. The default is ``"source"``.
231
- target : str, optional
240
+ edge_target_col : str, optional
232
241
  Column in ``edges_df`` containing target nodes. The default is ``"target"``.
233
- edge_weight : str, optional
242
+ edge_weight_col : str, optional
234
243
  Column in ``edges_df`` containing edge weights. The default is ``"weight"``.
235
- wordcloud_title : str, optional
236
- Title for the word cloud subplot. The default is ``None``.
237
- network_title : str, optional
238
- Title for the network subplot. The default is ``None``.
239
- wordcloud_style : StyleTemplate, optional
240
- Style configuration for the word cloud. The default is
241
- ``WORDCLOUD_STYLE_TEMPLATE``.
242
- network_style : StyleTemplate, optional
243
- Style configuration for the network graph. The default is
244
- ``NETWORK_STYLE_TEMPLATE``.
245
244
  max_words : int, optional
246
245
  Maximum number of words to include in the word cloud. The default is ``50``.
247
246
  stopwords : Iterable[str], optional
248
247
  Stopwords to exclude from the word cloud. The default is ``None``.
248
+ title : str, optional
249
+ Title for the composite figure. The default is ``None``.
250
+ style : StyleTemplate, optional
251
+ Shared style configuration applied to the composite figure and used for
252
+ subplots when specialized styles are not provided. The default is
253
+ ``WORDCLOUD_STYLE_TEMPLATE``.
254
+ wordcloud_style : StyleTemplate, optional
255
+ Optional style configuration for the word cloud subplot. When ``None``
256
+ the shared ``style`` is used. The default is ``None``.
257
+ network_style : StyleTemplate, optional
258
+ Optional style configuration for the network subplot. When ``None`` the
259
+ shared ``style`` is used. The default is ``None``.
249
260
  figsize : tuple[float, float], optional
250
261
  Size of the composite figure. The default is ``FIG_SIZE``.
251
262
 
@@ -254,35 +265,58 @@ def plot_wordcloud_network(
254
265
  Figure
255
266
  Matplotlib figure containing the word cloud on top and network below.
256
267
  """
257
- validate_dataframe(nodes_df, cols=[text_column], sort_by=node_weight)
258
- validate_dataframe(edges_df, cols=[source, target, edge_weight], sort_by=None)
268
+ validate_dataframe(nodes_df, cols=[node_col], sort_by=node_weight_col)
269
+ validate_dataframe(
270
+ edges_df, cols=[edge_source_col, edge_target_col, edge_weight_col], sort_by=None
271
+ )
259
272
 
260
- fig = cast(Figure, plt.figure(figsize=figsize))
261
- fig.patch.set_facecolor(wordcloud_style.background_color)
262
- grid = GridSpec(2, 1, height_ratios=[1, 2])
273
+ fig_raw, axes_raw = plt.subplots(
274
+ 2,
275
+ 1,
276
+ figsize=figsize,
277
+ gridspec_kw={"height_ratios": [1, 2]},
278
+ )
279
+ fig = cast(Figure, fig_raw)
280
+ wordcloud_ax, network_ax = cast(Tuple[Axes, Axes], axes_raw)
281
+
282
+ wordcloud_style = wordcloud_style or style
283
+ network_style = network_style or style
284
+
285
+ fig.patch.set_facecolor(style.background_color)
286
+ if title:
287
+ fig.suptitle(
288
+ title,
289
+ color=style.font_color,
290
+ fontsize=style.font_size * TITLE_SCALE_FACTOR,
291
+ fontname=style.font_name,
292
+ )
263
293
 
264
- wordcloud_ax = fig.add_subplot(grid[0, 0])
265
294
  aplot_wordcloud(
266
295
  pd_df=nodes_df,
267
- text_column=text_column,
268
- weight_column=node_weight,
269
- title=wordcloud_title,
296
+ text_column=node_col,
297
+ weight_column=node_weight_col,
298
+ title=None,
270
299
  style=wordcloud_style,
271
300
  max_words=max_words,
272
301
  stopwords=stopwords,
273
302
  ax=wordcloud_ax,
274
303
  )
275
304
 
276
- network_ax = fig.add_subplot(grid[1, 0])
277
305
  aplot_network(
278
306
  pd_df=edges_df,
279
- source=source,
280
- target=target,
281
- weight=edge_weight,
282
- title=network_title,
307
+ node_df=nodes_df,
308
+ node_col=node_col,
309
+ node_weight_col=node_weight_col,
310
+ edge_source_col=edge_source_col,
311
+ edge_target_col=edge_target_col,
312
+ edge_weight_col=edge_weight_col,
313
+ title=None,
283
314
  style=network_style,
284
315
  ax=network_ax,
285
316
  )
286
317
 
287
- fig.tight_layout()
318
+ if title:
319
+ fig.tight_layout(rect=(0, 0, 1, 0.95))
320
+ else:
321
+ fig.tight_layout()
288
322
  return fig