MatplotLibAPI 3.2.2__tar.gz → 3.2.4__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 (20) hide show
  1. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Bubble.py +3 -3
  2. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Composite.py +10 -7
  3. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Network.py +168 -82
  4. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Table.py +3 -3
  5. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Timeserie.py +3 -3
  6. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Treemap.py +1 -1
  7. matplotlibapi-3.2.4/MatplotLibAPI/__init__.py +277 -0
  8. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4/MatplotLibAPI.egg-info}/PKG-INFO +1 -1
  9. {matplotlibapi-3.2.2/MatplotLibAPI.egg-info → matplotlibapi-3.2.4}/PKG-INFO +1 -1
  10. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/pyproject.toml +1 -1
  11. matplotlibapi-3.2.2/MatplotLibAPI/__init__.py +0 -259
  12. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/LICENSE +0 -0
  13. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/Pivot.py +0 -0
  14. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI/StyleTemplate.py +0 -0
  15. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI.egg-info/SOURCES.txt +0 -0
  16. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI.egg-info/dependency_links.txt +0 -0
  17. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI.egg-info/requires.txt +0 -0
  18. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/MatplotLibAPI.egg-info/top_level.txt +0 -0
  19. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/README.md +0 -0
  20. {matplotlibapi-3.2.2 → matplotlibapi-3.2.4}/setup.cfg +0 -0
@@ -19,7 +19,7 @@ BUBBLE_STYLE_TEMPLATE = StyleTemplate(
19
19
  )
20
20
 
21
21
 
22
- def plot_bubble_ax(
22
+ def aplot_bubble(
23
23
  pd_df: pd.DataFrame,
24
24
  label: str,
25
25
  x: str,
@@ -125,7 +125,7 @@ def plot_bubble_ax(
125
125
  return ax
126
126
 
127
127
 
128
- def plot_bubble_fig(
128
+ def fplot_bubble(
129
129
  pd_df: pd.DataFrame,
130
130
  label: str,
131
131
  x: str,
@@ -144,7 +144,7 @@ def plot_bubble_fig(
144
144
  fig = plt.figure(figsize=figsize)
145
145
  fig.patch.set_facecolor(style.background_color)
146
146
  ax = fig.add_subplot()
147
- ax = plot_bubble_ax(pd_df=pd_df,
147
+ ax = aplot_bubble(pd_df=pd_df,
148
148
  label=label,
149
149
  x=x,
150
150
  y=y,
@@ -1,12 +1,14 @@
1
1
  # Hint for Visual Code Python Interactive window
2
2
  # %%
3
- from typing import Optional, Tuple
3
+ from typing import Optional, Tuple,List,Union, Dict
4
4
  import pandas as pd
5
5
  import matplotlib.pyplot as plt
6
+ from matplotlib.pyplot import GridSpec
6
7
  from matplotlib.figure import Figure
8
+ from matplotlib.axes import Axes
7
9
 
8
- from .Bubble import plot_bubble_ax, BUBBLE_STYLE_TEMPLATE
9
- from .Table import plot_table_ax
10
+ from .Bubble import aplot_bubble, BUBBLE_STYLE_TEMPLATE
11
+ from .Table import aplot_table
10
12
  from .StyleTemplate import StyleTemplate, format_func, validate_dataframe
11
13
 
12
14
 
@@ -41,7 +43,7 @@ def plot_composite_bubble(
41
43
  fig.patch.set_facecolor(style.background_color)
42
44
  grid = plt.GridSpec(2, 2, height_ratios=[2, 1], width_ratios=[1, 1])
43
45
  ax = fig.add_subplot(grid[0, 0:])
44
- ax = plot_bubble_ax(pd_df=plot_df,
46
+ ax = aplot_bubble(pd_df=plot_df,
45
47
  label=label,
46
48
  x=x,
47
49
  y=y,
@@ -64,7 +66,7 @@ def plot_composite_bubble(
64
66
  style.format_funcs[z] = style.format_funcs["z"]
65
67
 
66
68
  ax2 = fig.add_subplot(grid[1, 0])
67
- ax2 = plot_table_ax(
69
+ ax2 = aplot_table(
68
70
  pd_df=plot_df,
69
71
  cols=[label, z, y, x],
70
72
  title=f"Top {table_rows}",
@@ -75,10 +77,10 @@ def plot_composite_bubble(
75
77
  style=style
76
78
  )
77
79
  ax3 = fig.add_subplot(grid[1, 1])
78
- ax3 = plot_table_ax(
80
+ ax3 = aplot_table(
79
81
  pd_df=plot_df,
80
82
  cols=[label, z, y, x],
81
- title=f"Worst {table_rows}",
83
+ title=f"Last {table_rows}",
82
84
  ax=ax3,
83
85
  sort_by=sort_by,
84
86
  ascending=True,
@@ -87,3 +89,4 @@ def plot_composite_bubble(
87
89
  )
88
90
  fig.tight_layout()
89
91
  return fig
92
+
@@ -5,6 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple
5
5
 
6
6
  import matplotlib.pyplot as plt
7
7
  from matplotlib.axes import Axes
8
+ from matplotlib.figure import Figure
8
9
  import seaborn as sns
9
10
  import networkx as nx
10
11
  import numpy as np
@@ -13,7 +14,7 @@ from networkx import Graph
13
14
  from networkx.classes.graph import Graph
14
15
 
15
16
 
16
- from .StyleTemplate import StyleTemplate, string_formatter, format_func,validate_dataframe
17
+ from .StyleTemplate import StyleTemplate, string_formatter, format_func, validate_dataframe
17
18
 
18
19
  NETWORK_STYLE_TEMPLATE = StyleTemplate(
19
20
  )
@@ -89,13 +90,14 @@ class EdgeView(nx.classes.reportviews.EdgeView):
89
90
  return [(edge[0], edge[1]) for edge in filtered_edges]
90
91
 
91
92
 
92
- class Graph(nx.Graph):
93
+ class networkGraph():
93
94
  """
94
95
  Custom graph class based on NetworkX's Graph class.
95
96
  """
97
+ _nx_graph: nx.Graph
96
98
 
97
- def __init__(self):
98
- super().__init__()
99
+ def __init__(self, nx_graph: nx.Graph):
100
+ self._nx_graph = nx_graph
99
101
  self._scale = 1.0
100
102
 
101
103
  @property
@@ -108,7 +110,7 @@ class Graph(nx.Graph):
108
110
 
109
111
  @property
110
112
  def nodes(self):
111
- return NodeView(self)
113
+ return NodeView(self._nx_graph)
112
114
 
113
115
  @nodes.setter
114
116
  def scale(self, value: NodeView):
@@ -116,21 +118,22 @@ class Graph(nx.Graph):
116
118
 
117
119
  @property
118
120
  def edges(self):
119
- return EdgeView(self)
121
+ return EdgeView(self._nx_graph)
120
122
 
121
123
  @property
122
124
  def adjacency(self):
123
- return AdjacencyView(list(self))
125
+ return AdjacencyView(list(self._nx_graph))
124
126
 
125
- def edge_subgraph(self, edges: Iterable) -> Graph:
126
- return nx.edge_subgraph(self, edges)
127
+ def edge_subgraph(self, edges: Iterable) -> 'networkGraph':
128
+ return nx.edge_subgraph(self._nx_graph, edges)
127
129
 
128
130
  def layout(self,
129
131
  max_node_size: int = DEFAULT["MAX_NODES"],
130
132
  min_node_size: int = DEFAULT["MAX_NODES"],
131
133
  max_edge_width: int = DEFAULT["MAX_EDGE_WIDTH"],
132
134
  max_font_size: int = DEFAULT["MAX_FONT_SIZE"],
133
- min_font_size: int = DEFAULT["MIN_FONT_SIZE"]):
135
+ min_font_size: int = DEFAULT["MIN_FONT_SIZE"],
136
+ weight: str = "weight"):
134
137
  """
135
138
  Calculates the sizes for nodes, edges, and fonts based on node weights and edge weights.
136
139
 
@@ -144,13 +147,13 @@ class Graph(nx.Graph):
144
147
  and font sizes for node labels.
145
148
  """
146
149
  # Normalize and scale nodes' weights within the desired range of edge widths
147
- node_weights = [data.get('weight', 1)
150
+ node_weights = [data.get(weight, 1)
148
151
  for node, data in self.nodes(data=True)]
149
152
  node_size = scale_weights(
150
153
  weights=node_weights, scale_max=max_node_size, scale_min=min_node_size)
151
154
 
152
155
  # Normalize and scale edges' weights within the desired range of edge widths
153
- edge_weights = [data.get('weight', 0)
156
+ edge_weights = [data.get(weight, 1)
154
157
  for _, _, data in self.edges(data=True)]
155
158
  edges_width = scale_weights(
156
159
  weights=edge_weights, scale_max=max_edge_width)
@@ -165,7 +168,9 @@ class Graph(nx.Graph):
165
168
 
166
169
  return node_size, edges_width, fonts_size
167
170
 
168
- def subgraph(self, node_list=None, max_edges: int = DEFAULT["MAX_EDGES"]) -> Graph:
171
+ def subgraph(self,
172
+ node_list: Optional[List[str]] = None,
173
+ max_edges: int = DEFAULT["MAX_EDGES"]) -> 'networkGraph':
169
174
  if node_list is None:
170
175
  node_list = self.nodes.sort("weight")[:DEFAULT["MAX_NODES"]]
171
176
  connected_subgraph_nodes = list(self.find_connected_subgraph())
@@ -175,16 +180,18 @@ class Graph(nx.Graph):
175
180
  subgraph = nx.subgraph(self, nbunch=node_list)
176
181
  edges = subgraph.top_k_edges(attribute="weight", k=5).keys()
177
182
  subgraph = subgraph.edge_subgraph(list(edges)[:max_edges])
178
- return Graph(subgraph)
183
+ return networkGraph(subgraph)
179
184
 
180
185
  def plot_network(self,
181
- title: str = "Test",
182
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
183
- ax: Optional[Axes] = None) -> Axes:
186
+ title: Optional[str] = None,
187
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
188
+ weight: str = "weight",
189
+ ax: Optional[Axes] = None) -> Axes:
184
190
  """
185
191
  Plots the degree distribution of the graph, including a degree rank plot and a degree histogram.
186
192
  """
187
- degree_sequence = sorted([d for n, d in self.degree()], reverse=True)
193
+ degree_sequence = sorted(
194
+ [d for n, d in self._nx_graph.degree()], reverse=True)
188
195
  dmax = max(degree_sequence)
189
196
  sns.set_palette(style.palette)
190
197
  if ax is None:
@@ -195,21 +202,22 @@ class Graph(nx.Graph):
195
202
  max_node_size=DEFAULT["MAX_NODE_SIZE"],
196
203
  max_edge_width=DEFAULT["MAX_EDGE_WIDTH"],
197
204
  min_font_size=style.font_mapping.get(0),
198
- max_font_size=style.font_mapping.get(4))
199
- pos = nx.spring_layout(self, k=1)
205
+ max_font_size=style.font_mapping.get(4),
206
+ weight=weight)
207
+ pos = nx.spring_layout(self._nx_graph, k=1)
200
208
  # nodes
201
- nx.draw_networkx_nodes(self,
209
+ nx.draw_networkx_nodes(self._nx_graph,
202
210
  pos,
203
211
  ax=ax,
204
212
  node_size=list(node_sizes),
205
213
  node_color=node_sizes,
206
- cmap=plt.cm.get_cmap(style.palette))
214
+ cmap=plt.get_cmap(style.palette))
207
215
  # edges
208
- nx.draw_networkx_edges(self,
216
+ nx.draw_networkx_edges(self._nx_graph,
209
217
  pos,
210
218
  ax=ax,
211
219
  edge_color=style.font_color,
212
- edge_cmap=plt.cm.get_cmap(style.palette),
220
+ edge_cmap=plt.get_cmap(style.palette),
213
221
  width=edge_widths)
214
222
  # labels
215
223
  for font_size, nodes in font_sizes.items():
@@ -221,34 +229,37 @@ class Graph(nx.Graph):
221
229
  font_color=style.font_color,
222
230
  labels={n: string_formatter(n) for n in nodes})
223
231
  ax.set_facecolor(style.background_color)
224
- ax.set_title(title, color=style.font_color, fontsize=style.font_size*2)
232
+ if title:
233
+ ax.set_title(title, color=style.font_color,
234
+ fontsize=style.font_size*2)
225
235
  ax.set_axis_off()
226
236
 
227
237
  return ax
228
238
 
229
- def plot_network_components(self, node_list: Optional[List] = None,
230
- scale: int = DEFAULT["GRAPH_SCALE"],
231
- node_scale: int = DEFAULT["MAX_NODE_SIZE"],
232
- edge_scale: float = DEFAULT["MAX_EDGE_WIDTH"],
233
- max_nodes: int = DEFAULT["MAX_NODES"],
234
- max_edges: int = DEFAULT["MAX_EDGES"],
235
- plt_title: Optional[str] = "Top keywords"):
239
+ def plot_network_components(self,
240
+ node_list: Optional[List] = None,
241
+ scale: int = DEFAULT["GRAPH_SCALE"],
242
+ node_scale: int = DEFAULT["MAX_NODE_SIZE"],
243
+ edge_scale: float = DEFAULT["MAX_EDGE_WIDTH"],
244
+ max_nodes: int = DEFAULT["MAX_NODES"],
245
+ max_edges: int = DEFAULT["MAX_EDGES"],
246
+ plt_title: Optional[str] = "Top keywords"):
236
247
  # node_list=self.nodes_circuits(node_list)
237
248
  g = self.subgraph(max_edges=max_edges, node_list=node_list)
238
249
  connected_components = nx.connected_components(g)
239
- axes=[]
250
+ axes = []
240
251
  for connected_component in connected_components:
241
252
  if len(connected_component) > 5:
242
253
  connected_component_graph = self.subgraph(max_edges=max_edges,
243
254
  node_list=connected_component)
244
- ax=connected_component_graph.plot_network()
255
+ ax = connected_component_graph.plot_network()
245
256
  axes.append(ax)
246
257
  return axes
247
258
 
248
- def find_connected_subgraph(self):
259
+ def find_connected_subgraph(self) -> 'networkGraph':
249
260
  logging.info(f'find_connected_subgraph')
250
261
  # Copy the original graph to avoid modifying it
251
- H = self.copy()
262
+ H = self._nx_graph.copy()
252
263
 
253
264
  # Flag to keep track of whether any node with degree < 2 was removed
254
265
  removed_node = True
@@ -265,7 +276,7 @@ class Graph(nx.Graph):
265
276
  removed_node = True
266
277
  break
267
278
 
268
- return H
279
+ return networkGraph(H)
269
280
 
270
281
  def top_k_edges(self, attribute: str, reverse: bool = True, k: int = 5) -> Dict[Any, List[Tuple[Any, Dict]]]:
271
282
  """
@@ -297,7 +308,7 @@ class Graph(nx.Graph):
297
308
  def from_pandas_edgelist(df: pd.DataFrame,
298
309
  source: str = "source",
299
310
  target: str = "target",
300
- weight: str = "weight") -> Graph:
311
+ weight: str = "weight") -> 'networkGraph':
301
312
  """
302
313
  Initialize netX instance with a simple dataframe
303
314
 
@@ -307,11 +318,12 @@ class Graph(nx.Graph):
307
318
  :param weight: Name of edges weight column in df_source.
308
319
 
309
320
  """
310
- G = nx.from_pandas_edgelist(
311
- df, source=source, target=target, edge_attr=weight, create_using=G)
312
- G = G.find_connected_subgraph()
321
+ network_G = nx.from_pandas_edgelist(
322
+ df, source=source, target=target, edge_attr=weight)
323
+ network_G = networkGraph(network_G)
324
+ network_G = network_G.find_connected_subgraph()
313
325
 
314
- edge_aggregates = G.top_k_edges(attribute=weight, k=10)
326
+ edge_aggregates = network_G.top_k_edges(attribute=weight, k=10)
315
327
  node_aggregates = {}
316
328
  for (u, v), weight_value in edge_aggregates.items():
317
329
  if u not in node_aggregates:
@@ -321,62 +333,136 @@ class Graph(nx.Graph):
321
333
  node_aggregates[u] += weight_value
322
334
  node_aggregates[v] += weight_value
323
335
 
324
- nx.set_node_attributes(G, node_aggregates, name=weight)
336
+ nx.set_node_attributes(network_G, node_aggregates, name=weight)
325
337
 
326
- G = G.edge_subgraph(edges=G.top_k_edges(attribute=weight))
327
- return Graph(G)
338
+ network_G = network_G.edge_subgraph(
339
+ edges=network_G.top_k_edges(attribute=weight))
340
+ return networkGraph(network_G)
328
341
 
329
342
 
330
- def plot_network(pd_df: pd.DataFrame,
331
- source: str = "source",
332
- target: str = "target",
333
- weight: str = "weight",
334
- title: str = "Test",
335
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
336
- sort_by: Optional[str] = None,
337
- ascending: bool = False,
338
- node_list: Optional[List] = None,
339
- ax: Optional[Axes] = None) -> Axes:
343
+ def aplot_network(pd_df: pd.DataFrame,
344
+ source: str = "source",
345
+ target: str = "target",
346
+ weight: str = "weight",
347
+ title: Optional[str] = None,
348
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
349
+ sort_by: Optional[str] = None,
350
+ ascending: bool = False,
351
+ node_list: Optional[List] = None,
352
+ ax: Optional[Axes] = None) -> Axes:
340
353
  if node_list:
341
- df = pd_df[(pd_df["source"].isin(node_list)) | (pd_df["target"].isin(node_list))]
354
+ df = pd_df[(pd_df["source"].isin(node_list)) |
355
+ (pd_df["target"].isin(node_list))]
342
356
  else:
343
357
  df = pd_df
344
358
  validate_dataframe(df, cols=[source, target, weight], sort_by=sort_by)
345
359
 
346
- graph = Graph.from_pandas_edgelist(df,
347
- source=source,
348
- target=target,
349
- weight=weight)
360
+ graph = networkGraph.from_pandas_edgelist(df,
361
+ source=source,
362
+ target=target,
363
+ weight=weight)
350
364
  return graph.plot_network(title=title,
351
- style=style,
352
- ax=ax)
353
-
354
- def plot_network_components(pd_df: pd.DataFrame,
355
- source: str = "source",
356
- target: str = "target",
357
- weight: str = "weight",
358
- title: str = "Test",
359
- style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
360
- sort_by: Optional[str] = None,
361
- node_list: Optional[List] = None,
362
- ascending: bool = False,
363
- ax: Optional[List[Axes]] = None) -> List[Axes]:
365
+ style=style,
366
+ weight=weight,
367
+ ax=ax)
368
+
369
+
370
+ def aplot_network_components(pd_df: pd.DataFrame,
371
+ source: str = "source",
372
+ target: str = "target",
373
+ weight: str = "weight",
374
+ title: Optional[str] = None,
375
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
376
+ sort_by: Optional[str] = None,
377
+ node_list: Optional[List] = None,
378
+ ascending: bool = False,
379
+ ax: Optional[List[Axes]] = None) -> List[Axes]:
364
380
  if node_list:
365
- df = pd_df[(pd_df["source"].isin(node_list)) | (pd_df["target"].isin(node_list))]
381
+ df = pd_df[(pd_df["source"].isin(node_list)) |
382
+ (pd_df["target"].isin(node_list))]
366
383
  else:
367
384
  df = pd_df
368
385
  validate_dataframe(df, cols=[source, target, weight], sort_by=sort_by)
369
386
 
370
- graph = Graph.from_pandas_edgelist(df,
371
- source=source,
372
- target=target,
373
- weight=weight)
387
+ graph = networkGraph.from_pandas_edgelist(df,
388
+ source=source,
389
+ target=target,
390
+ weight=weight)
374
391
  connected_components = nx.connected_components(graph)
375
- axes=[]
392
+ axes = []
393
+ i = 0
376
394
  for connected_component in connected_components:
377
395
  if len(connected_component) > 5:
378
- connected_component_graph = graph.subgraph(node_list=connected_component)
379
- ax=connected_component_graph.plot_network()
396
+ connected_component_graph = graph.subgraph(
397
+ node_list=connected_component)
398
+ ax = connected_component_graph.plot_network(title=f"{title}::{i}",
399
+ style=style,
400
+ weight=weight,
401
+ ax=ax)
380
402
  axes.append(ax)
403
+ i += 1
381
404
  return axes
382
-
405
+
406
+
407
+ def fplot_network(pd_df: pd.DataFrame,
408
+ source: str = "source",
409
+ target: str = "target",
410
+ weight: str = "weight",
411
+ title: Optional[str] = None,
412
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
413
+ sort_by: Optional[str] = None,
414
+ ascending: bool = False,
415
+ node_list: Optional[List] = None,
416
+ figsize: Tuple[float, float] = (19.2, 10.8)) -> Figure:
417
+ fig = plt.figure(figsize=figsize)
418
+ fig.patch.set_facecolor(style.background_color)
419
+ ax = fig.add_subplot()
420
+ ax = aplot_network(pd_df,
421
+ source=source,
422
+ target=target,
423
+ weight=weight,
424
+ title=title,
425
+ style=style,
426
+ sort_by=sort_by,
427
+ ascending=ascending,
428
+ node_list=node_list,
429
+ ax=ax
430
+ )
431
+ return fig
432
+
433
+
434
+ def fplot_network_components(pd_df: pd.DataFrame,
435
+ source: str = "source",
436
+ target: str = "target",
437
+ weight: str = "weight",
438
+ title: Optional[str] = None,
439
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
440
+ sort_by: Optional[str] = None,
441
+ ascending: bool = False,
442
+ node_list: Optional[List] = None,
443
+ figsize: Tuple[float, float] = (19.2, 10.8)) -> Figure:
444
+ axes = aplot_network_components(pd_df,
445
+ source=source,
446
+ target=target,
447
+ weight=weight,
448
+ title=title,
449
+ style=style,
450
+ sort_by=sort_by,
451
+ ascending=ascending,
452
+ node_list=node_list
453
+ )
454
+ fig = plt.figure(figsize=figsize)
455
+ fig.patch.set_facecolor(style.background_color)
456
+ ax = fig.add_subplot()
457
+ ax = aplot_network(pd_df,
458
+ source=source,
459
+ target=target,
460
+ weight=weight,
461
+ title=title,
462
+ style=style,
463
+ sort_by=sort_by,
464
+ ascending=ascending,
465
+ node_list=node_list,
466
+ ax=ax
467
+ )
468
+ return fig
@@ -14,7 +14,7 @@ TABLE_STYLE_TEMPLATE = StyleTemplate(
14
14
  )
15
15
 
16
16
 
17
- def plot_table_ax(pd_df: pd.DataFrame,
17
+ def aplot_table(pd_df: pd.DataFrame,
18
18
  cols: List[str],
19
19
  title: Optional[str] = None,
20
20
  style: StyleTemplate = TABLE_STYLE_TEMPLATE,
@@ -67,7 +67,7 @@ def plot_table_ax(pd_df: pd.DataFrame,
67
67
  return ax
68
68
 
69
69
 
70
- def plot_table_fig(pd_df: pd.DataFrame,
70
+ def fplot_table(pd_df: pd.DataFrame,
71
71
  cols: List[str],
72
72
  title: Optional[str] = None,
73
73
  style: StyleTemplate = TABLE_STYLE_TEMPLATE,
@@ -79,7 +79,7 @@ def plot_table_fig(pd_df: pd.DataFrame,
79
79
  fig = plt.figure(figsize=figsize)
80
80
  fig.patch.set_facecolor(style.background_color)
81
81
  ax = fig.add_subplot()
82
- ax = plot_table_ax(pd_df,
82
+ ax = aplot_table(pd_df,
83
83
  cols,
84
84
  title,
85
85
  style,
@@ -18,7 +18,7 @@ TIMESERIE_STYLE_TEMPLATE = StyleTemplate(
18
18
  # region Line
19
19
 
20
20
 
21
- def plot_timeserie_ax(pd_df: pd.DataFrame,
21
+ def aplot_timeserie(pd_df: pd.DataFrame,
22
22
  label: str,
23
23
  x: str,
24
24
  y: str,
@@ -99,7 +99,7 @@ def plot_timeserie_ax(pd_df: pd.DataFrame,
99
99
  return ax
100
100
 
101
101
 
102
- def plot_timeserie_fig(pd_df: pd.DataFrame,
102
+ def fplot_timeserie(pd_df: pd.DataFrame,
103
103
  label: str,
104
104
  x: str,
105
105
  y: str,
@@ -113,7 +113,7 @@ def plot_timeserie_fig(pd_df: pd.DataFrame,
113
113
  fig = plt.figure(figsize=figsize)
114
114
  fig.patch.set_facecolor(style.background_color)
115
115
  ax = fig.add_subplot()
116
- ax = plot_timeserie_ax(pd_df=pd_df,
116
+ ax = aplot_timeserie(pd_df=pd_df,
117
117
  label=label,
118
118
  x=x,
119
119
  y=y,
@@ -19,7 +19,7 @@ TREEMAP_STYLE_TEMPLATE = StyleTemplate(
19
19
  )
20
20
 
21
21
 
22
- def plot_treemap(pd_df: pd.DataFrame,
22
+ def fplot_treemap(pd_df: pd.DataFrame,
23
23
  path: str,
24
24
  values: str,
25
25
  style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
@@ -0,0 +1,277 @@
1
+
2
+ from .StyleTemplate import StyleTemplate
3
+ from .Bubble import aplot_bubble, fplot_bubble, BUBBLE_STYLE_TEMPLATE
4
+ from .Composite import plot_composite_bubble
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, TREEMAP_STYLE_TEMPLATE
9
+ from typing import List, Optional, Tuple
10
+ import pandas as pd
11
+ from pandas.api.extensions import register_dataframe_accessor
12
+
13
+ from matplotlib.axes import Axes
14
+ from matplotlib.figure import Figure
15
+ import plotly.graph_objects as go
16
+
17
+
18
+ @register_dataframe_accessor("mpl")
19
+ class DataFrameAccessor:
20
+
21
+ def __init__(self, pd_df: pd.DataFrame):
22
+ self._obj = pd_df
23
+
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) -> Figure:
95
+
96
+ return plot_composite_bubble(pd_df=self._obj,
97
+ label=label,
98
+ x=x,
99
+ y=y,
100
+ z=z,
101
+ title=title,
102
+ style=style,
103
+ max_values=max_values,
104
+ center_to_mean=center_to_mean,
105
+ sort_by=sort_by,
106
+ ascending=ascending)
107
+
108
+ def aplot_table_ax(self,
109
+ cols: List[str],
110
+ title: Optional[str] = None,
111
+ style: StyleTemplate = TABLE_STYLE_TEMPLATE,
112
+ max_values: int = 20,
113
+ sort_by: Optional[str] = None,
114
+ ascending: bool = False,
115
+ ax: Optional[Axes] = None) -> Axes:
116
+
117
+ return aplot_table(pd_df=self._obj,
118
+ cols=cols,
119
+ title=title,
120
+ style=style,
121
+ max_values=max_values,
122
+ sort_by=sort_by,
123
+ ascending=ascending,
124
+ ax=ax)
125
+
126
+ def fplot_table(self,
127
+ cols: List[str],
128
+ title: Optional[str] = None,
129
+ style: StyleTemplate = TABLE_STYLE_TEMPLATE,
130
+ max_values: int = 20,
131
+ sort_by: Optional[str] = None,
132
+ ascending: bool = False,
133
+ figsize: Tuple[float, float] = (19.2, 10.8)) -> Axes:
134
+
135
+ return fplot_table(pd_df=self._obj,
136
+ cols=cols,
137
+ title=title,
138
+ style=style,
139
+ max_values=max_values,
140
+ sort_by=sort_by,
141
+ ascending=ascending,
142
+ figsize=figsize)
143
+
144
+ def aplot_timeserie(self,
145
+ label: str,
146
+ x: str,
147
+ y: str,
148
+ title: Optional[str] = None,
149
+ style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
150
+ max_values: int = 100,
151
+ sort_by: Optional[str] = None,
152
+ ascending: bool = False,
153
+ std: bool = False,
154
+ ax: Optional[Axes] = None) -> Axes:
155
+
156
+ return aplot_timeserie(pd_df=self._obj,
157
+ label=label,
158
+ x=x,
159
+ y=y,
160
+ title=title,
161
+ style=style,
162
+ max_values=max_values,
163
+ sort_by=sort_by,
164
+ ascending=ascending,
165
+ std=std,
166
+ ax=ax)
167
+
168
+ def fplot_timeserie(self,
169
+ label: str,
170
+ x: str,
171
+ y: str,
172
+ title: Optional[str] = None,
173
+ style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
174
+ max_values: int = 100,
175
+ sort_by: Optional[str] = None,
176
+ ascending: bool = False,
177
+ std: bool = False,
178
+ figsize: Tuple[float, float] = (19.2, 10.8)) -> Axes:
179
+
180
+ return fplot_timeserie(pd_df=self._obj,
181
+ label=label,
182
+ x=x,
183
+ y=y,
184
+ title=title,
185
+ style=style,
186
+ max_values=max_values,
187
+ sort_by=sort_by,
188
+ ascending=ascending,
189
+ std=std,
190
+ figsize=figsize)
191
+
192
+ def aplot_network(self,
193
+ source: str = "source",
194
+ target: str = "target",
195
+ weight: str = "weight",
196
+ title: Optional[str] = None,
197
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
198
+ sort_by: Optional[str] = None,
199
+ ascending: bool = False,
200
+ node_list: Optional[List] = None,
201
+ ax: Optional[Axes] = None) -> Axes:
202
+
203
+ return aplot_network(pd_df=self._obj,
204
+ source=source,
205
+ target=target,
206
+ weight=weight,
207
+ title=title,
208
+ style=style,
209
+ sort_by=sort_by,
210
+ ascending=ascending,
211
+ node_list=node_list,
212
+ ax=ax)
213
+
214
+ def aplot_network_components(self,
215
+ source: str = "source",
216
+ target: str = "target",
217
+ weight: str = "weight",
218
+ title: Optional[str] = None,
219
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
220
+ sort_by: Optional[str] = None,
221
+ ascending: bool = False,
222
+ node_list: Optional[List] = None,
223
+ ax: Optional[Axes] = None) -> Axes:
224
+
225
+ return aplot_network_components(df=self._obj,
226
+ source=source,
227
+ target=target,
228
+ weight=weight,
229
+ title=title,
230
+ style=style,
231
+ sort_by=sort_by,
232
+ ascending=ascending,
233
+ node_list=node_list,
234
+ ax=ax)
235
+
236
+ def fplot_network(self,
237
+ source: str = "source",
238
+ target: str = "target",
239
+ weight: str = "weight",
240
+ title: Optional[str] = None,
241
+ style: StyleTemplate = NETWORK_STYLE_TEMPLATE,
242
+ sort_by: Optional[str] = None,
243
+ ascending: bool = False,
244
+ node_list: Optional[List] = None) -> Axes:
245
+
246
+ return fplot_network(pd_df=self._obj,
247
+ source=source,
248
+ target=target,
249
+ weight=weight,
250
+ title=title,
251
+ style=style,
252
+ sort_by=sort_by,
253
+ ascending=ascending,
254
+ node_list=node_list)
255
+
256
+ def fplot_treemap(self,
257
+ path: str,
258
+ values: str,
259
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
260
+ title: Optional[str] = None,
261
+ color: Optional[str] = None,
262
+ max_values: int = 100,
263
+ sort_by: Optional[str] = None,
264
+ ascending: bool = False) -> go.Figure:
265
+ return fplot_treemap(pd_df=self._obj,
266
+ path=path,
267
+ values=values,
268
+ title=title,
269
+ style=style,
270
+ color=color,
271
+ max_values=max_values,
272
+ sort_by=sort_by,
273
+ ascending=ascending)
274
+
275
+
276
+ __all__ = ["validate_dataframe", "aplot_bubble", "aplot_timeserie", "aplot_table", "aplot_network", "aplot_network_components", "fplot_network",
277
+ "plot_pivotbar", "fplot_treemap", "plot_composite_bubble", "StyleTemplate", "DataFrameAccessor"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Requires-Python: >=3.7
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.2.2
3
+ Version: 3.2.4
4
4
  Requires-Python: >=3.7
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "MatplotLibAPI"
6
- version="v3.2.2"
6
+ version="v3.2.4"
7
7
  readme = "README.md"
8
8
  requires-python=">=3.7"
9
9
  dependencies = ["pandas","matplotlib","networkx","plotly","seaborn","scikit-learn","kaleido","nbformat"]
@@ -1,259 +0,0 @@
1
-
2
- from .StyleTemplate import StyleTemplate
3
- from .Bubble import plot_bubble_ax, plot_bubble_fig, BUBBLE_STYLE_TEMPLATE
4
- from .Composite import plot_composite_bubble
5
- from .Timeserie import plot_timeserie_ax, plot_timeserie_fig, TIMESERIE_STYLE_TEMPLATE
6
- from .Table import plot_table_ax, plot_table_fig, TABLE_STYLE_TEMPLATE
7
- from .Network import plot_network, plot_network_components, NETWORK_STYLE_TEMPLATE
8
- from .Treemap import plot_treemap, TREEMAP_STYLE_TEMPLATE
9
- from typing import List, Optional, Tuple
10
- import pandas as pd
11
- from pandas.api.extensions import register_dataframe_accessor
12
-
13
- from matplotlib.axes import Axes
14
- from matplotlib.figure import Figure
15
- import plotly.graph_objects as go
16
-
17
-
18
- @register_dataframe_accessor("mpl")
19
- class DataFrameAccessor:
20
-
21
- def __init__(self, pd_df: pd.DataFrame):
22
- self._obj = pd_df
23
-
24
- def plot_bubble_ax(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 plot_bubble_ax(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 plot_bubble_fig(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 plot_bubble_fig(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 plot_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
- ax: Optional[Axes] = None) -> 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
- ax=ax)
109
-
110
- def plot_table_ax(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 plot_table_ax(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 plot_table_fig(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 plot_table_fig(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 plot_timeserie_ax(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 plot_timeserie_ax(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 plot_timeserie_fig(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 plot_timeserie_fig(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 plot_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 plot_network(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 plot_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 plot_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 plot_treemap(self,
239
- path: str,
240
- values: str,
241
- style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
242
- title: Optional[str] = None,
243
- color: Optional[str] = None,
244
- max_values: int = 100,
245
- sort_by: Optional[str] = None,
246
- ascending: bool = False) -> go.Figure:
247
- return plot_treemap(pd_df=self._obj,
248
- path=path,
249
- values=values,
250
- title=title,
251
- style=style,
252
- color=color,
253
- max_values=max_values,
254
- sort_by=sort_by,
255
- ascending=ascending)
256
-
257
-
258
- __all__ = ["validate_dataframe", "plot_bubble_ax", "plot_timeserie_ax", "plot_table_ax", "plot_network", "plot_network_components",
259
- "plot_pivotbar", "plot_treemap", "plot_composite_bubble", "StyleTemplate", "DataFrameAccessor"]
File without changes
File without changes
File without changes