MatplotLibAPI 3.2.7__py3-none-any.whl → 3.2.8__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.
@@ -1,15 +1,14 @@
1
1
  # Hint for Visual Code Python Interactive window
2
2
  # %%
3
- from typing import Optional, Tuple, List, Union, Dict
3
+ from typing import Optional, Tuple, List
4
4
  import pandas as pd
5
5
  import matplotlib.pyplot as plt
6
- from matplotlib.pyplot import GridSpec
7
6
  from matplotlib.figure import Figure
8
- from matplotlib.axes import Axes
9
7
  import plotly.graph_objects as go
8
+ from plotly.subplots import make_subplots
10
9
  from .Bubble import aplot_bubble, BUBBLE_STYLE_TEMPLATE
11
10
  from .Table import aplot_table
12
- from .Treemap import fplot_treemap, TREEMAP_STYLE_TEMPLATE
11
+ from .Treemap import aplot_treemap, TREEMAP_STYLE_TEMPLATE
13
12
  from .StyleTemplate import StyleTemplate, format_func, validate_dataframe
14
13
 
15
14
 
@@ -91,7 +90,7 @@ def plot_composite_bubble(
91
90
  return fig
92
91
 
93
92
 
94
- def fplot_treemaps(pd_dfs: List[pd.DataFrame],
93
+ def plot_composite_treemap(pd_dfs: List[pd.DataFrame],
95
94
  path: str,
96
95
  values: str,
97
96
  style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
@@ -101,7 +100,6 @@ def fplot_treemaps(pd_dfs: List[pd.DataFrame],
101
100
  ascending: bool = False,
102
101
  max_values: int = 100) -> go.Figure:
103
102
 
104
- trms = []
105
103
  num_dimensions = len(pd_dfs)
106
104
  if num_dimensions > 0:
107
105
  fig = make_subplots(
@@ -110,9 +108,9 @@ def fplot_treemaps(pd_dfs: List[pd.DataFrame],
110
108
  specs=[[{'type': 'domain'}] for _ in range(num_dimensions)],
111
109
  vertical_spacing=0.02
112
110
  )
113
- current_row = 0
111
+ current_row = 1
114
112
  for pd_df in pd_dfs:
115
- trm = fplot_treemap(pd_df=pd_df,
113
+ trm = aplot_treemap(pd_df=pd_df,
116
114
  path=path,
117
115
  values=values,
118
116
  title=title,
@@ -120,7 +118,7 @@ def fplot_treemaps(pd_dfs: List[pd.DataFrame],
120
118
  color=color,
121
119
  sort_by=sort_by,
122
120
  ascending=ascending,
123
- max_values=max_values,
124
- fig=fig)
125
- trms.append(trm)
121
+ max_values=max_values)
122
+ fig.add_trace(trm,row=current_row, col=1)
126
123
  current_row += 1
124
+ return fig
MatplotLibAPI/Treemap.py CHANGED
@@ -2,11 +2,10 @@
2
2
  # %%
3
3
  from typing import Optional
4
4
  import pandas as pd
5
- from pandas import CategoricalDtype,BooleanDtype
5
+ from pandas import CategoricalDtype, BooleanDtype
6
6
  import plotly.graph_objects as go
7
7
 
8
- from .StyleTemplate import StyleTemplate, string_formatter, percent_formatter,validate_dataframe
9
-
8
+ from .StyleTemplate import StyleTemplate, string_formatter, percent_formatter, validate_dataframe
10
9
 
11
10
 
12
11
  TREEMAP_STYLE_TEMPLATE = StyleTemplate(
@@ -19,16 +18,15 @@ TREEMAP_STYLE_TEMPLATE = StyleTemplate(
19
18
  )
20
19
 
21
20
 
22
- def fplot_treemap(pd_df: pd.DataFrame,
23
- path: str,
24
- values: str,
25
- style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
26
- title: Optional[str] = None,
27
- color: Optional[str] = None,
28
- sort_by: Optional[str] = None,
29
- ascending: bool = False,
30
- max_values: int = 100,
31
- fig: Optional[go.Figure] = None) -> go.Figure:
21
+ def aplot_treemap(pd_df: pd.DataFrame,
22
+ path: str,
23
+ values: str,
24
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
25
+ title: Optional[str] = None,
26
+ color: Optional[str] = None,
27
+ sort_by: Optional[str] = None,
28
+ ascending: bool = False,
29
+ max_values: int = 100) -> go.Trace:
32
30
  cols = [path, values]
33
31
  if color:
34
32
  cols.append(color)
@@ -57,7 +55,33 @@ def fplot_treemap(pd_df: pd.DataFrame,
57
55
  data['marker'] = dict(colorscale="Viridis",
58
56
  colors=color_data.to_list())
59
57
 
60
- g = go.Treemap(data)
58
+ g = go.Treemap(data,
59
+ root_color=style.background_color
60
+ )
61
+
62
+ return g
63
+
64
+
65
+ def fplot_treemap(pd_df: pd.DataFrame,
66
+ path: str,
67
+ values: str,
68
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
69
+ title: Optional[str] = None,
70
+ color: Optional[str] = None,
71
+ sort_by: Optional[str] = None,
72
+ ascending: bool = False,
73
+ max_values: int = 100,
74
+ fig: Optional[go.Figure] = None) -> go.Figure:
75
+
76
+ g = aplot_treemap(pd_df=pd_df,
77
+ path=path,
78
+ values=values,
79
+ title=title,
80
+ style=style,
81
+ color=color,
82
+ sort_by=sort_by,
83
+ ascending=ascending,
84
+ max_values=max_values)
61
85
 
62
86
  if not fig:
63
87
  fig = go.Figure(g)
MatplotLibAPI/__init__.py CHANGED
@@ -5,7 +5,7 @@ from .Composite import plot_composite_bubble
5
5
  from .Timeserie import aplot_timeserie, fplot_timeserie, TIMESERIE_STYLE_TEMPLATE
6
6
  from .Table import aplot_table, fplot_table, TABLE_STYLE_TEMPLATE
7
7
  from .Network import aplot_network, aplot_network_components, fplot_network, NETWORK_STYLE_TEMPLATE
8
- from .Treemap import fplot_treemap, TREEMAP_STYLE_TEMPLATE
8
+ from .Treemap import fplot_treemap, aplot_treemap, TREEMAP_STYLE_TEMPLATE
9
9
  from typing import List, Optional, Tuple
10
10
  import pandas as pd
11
11
  from pandas.api.extensions import register_dataframe_accessor
@@ -274,6 +274,26 @@ class DataFrameAccessor:
274
274
  max_values=max_values,
275
275
  fig=fig)
276
276
 
277
+ def aplot_treemap(self,
278
+ path: str,
279
+ values: str,
280
+ style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
281
+ title: Optional[str] = None,
282
+ color: Optional[str] = None,
283
+ sort_by: Optional[str] = None,
284
+ max_values: int = 100,
285
+ ascending: bool = False,
286
+ fig: Optional[go.Figure] = None) -> go.Figure:
287
+ return aplot_treemap(pd_df=self._obj,
288
+ path=path,
289
+ values=values,
290
+ title=title,
291
+ style=style,
292
+ color=color,
293
+ sort_by=sort_by,
294
+ ascending=ascending,
295
+ max_values=max_values)
296
+
277
297
 
278
298
  __all__ = ["validate_dataframe", "aplot_bubble", "aplot_timeserie", "aplot_table", "aplot_network", "aplot_network_components", "fplot_network",
279
- "plot_pivotbar", "fplot_treemap", "plot_composite_bubble", "StyleTemplate", "DataFrameAccessor"]
299
+ "plot_pivotbar", "fplot_treemap", "aplot_treemap", "plot_composite_bubble", "StyleTemplate", "DataFrameAccessor"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.2.7
3
+ Version: 3.2.8
4
4
  Requires-Python: >=3.7
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,14 +1,14 @@
1
1
  MatplotLibAPI/Bubble.py,sha256=ZtOTWGAnJ1zy7bjKQ3OF985R-iZHvZOo_rG1dZMbP-Q,5116
2
- MatplotLibAPI/Composite.py,sha256=AolGqsz5brc9bx4lfp9phWTfFpdlXMq4hrAGkJHJmfQ,4268
2
+ MatplotLibAPI/Composite.py,sha256=YpC4VxYX4nMgiiV8ic734c_NGaCTdQCptT8bpMdTqCQ,4222
3
3
  MatplotLibAPI/Network.py,sha256=zzizLBAMD-nV-1WGZTIoOQn3SVsvr9R8Ba2DTCyuTvA,18790
4
4
  MatplotLibAPI/Pivot.py,sha256=Bo7ZpkxqoE75e8vpSsKIT5X2Q7lLdfAyy46ox1fARbc,7183
5
5
  MatplotLibAPI/StyleTemplate.py,sha256=va8_yXaun1RnjQUOEHGvsXJrKWHdzz4BhnY0CkROLW8,4599
6
6
  MatplotLibAPI/Table.py,sha256=p_nHXRiC6dneBSf0j5nx-hBijBSXd7NBLmdBicFUGqQ,2809
7
7
  MatplotLibAPI/Timeserie.py,sha256=B03xjcBCgWVpkDQKvoyGtNjm6OLtCo1fINyXJrXeWM8,4952
8
- MatplotLibAPI/Treemap.py,sha256=1QqBnV1EUzDHPSnp90n3TQKLZMuTymaJFZIdVJQqdjI,2553
9
- MatplotLibAPI/__init__.py,sha256=X_BhQQMYO-CLmsYf1_9eLnjZs3B2TzjfYZqxQCkyyPc,12000
10
- MatplotLibAPI-3.2.7.dist-info/LICENSE,sha256=hMErKLb6YZR3lRR5zr-vxeFkvY69QAaafgSpZ5-P1dQ,1067
11
- MatplotLibAPI-3.2.7.dist-info/METADATA,sha256=bri6ND9ICIsgmLhQJL3XxaePkCpBYboaqk2QZ1RqAJI,462
12
- MatplotLibAPI-3.2.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
- MatplotLibAPI-3.2.7.dist-info/top_level.txt,sha256=MrzbBjDEW48Vb6YhQIqpFYGOhHzQnEIM5Qy2xy2iqew,14
14
- MatplotLibAPI-3.2.7.dist-info/RECORD,,
8
+ MatplotLibAPI/Treemap.py,sha256=1WYHV9eaU4zcXrwTIScQvsGrfgiuYg-aAoeIhTZVPKw,3395
9
+ MatplotLibAPI/__init__.py,sha256=-NgOIPG0P7G4pllESRsrOzcKgT0u-ZSE04AHRk-8Aas,12918
10
+ MatplotLibAPI-3.2.8.dist-info/LICENSE,sha256=hMErKLb6YZR3lRR5zr-vxeFkvY69QAaafgSpZ5-P1dQ,1067
11
+ MatplotLibAPI-3.2.8.dist-info/METADATA,sha256=X-bNBBQloDBC8Np3t6YsFWi3AjJ3AG_OOH9GdEJAudU,462
12
+ MatplotLibAPI-3.2.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
+ MatplotLibAPI-3.2.8.dist-info/top_level.txt,sha256=MrzbBjDEW48Vb6YhQIqpFYGOhHzQnEIM5Qy2xy2iqew,14
14
+ MatplotLibAPI-3.2.8.dist-info/RECORD,,