MatplotLibAPI 3.2.5__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.
- MatplotLibAPI/Composite.py +48 -16
- MatplotLibAPI/Treemap.py +38 -14
- MatplotLibAPI/__init__.py +34 -12
- {MatplotLibAPI-3.2.5.dist-info → MatplotLibAPI-3.2.8.dist-info}/METADATA +1 -1
- {MatplotLibAPI-3.2.5.dist-info → MatplotLibAPI-3.2.8.dist-info}/RECORD +8 -8
- {MatplotLibAPI-3.2.5.dist-info → MatplotLibAPI-3.2.8.dist-info}/LICENSE +0 -0
- {MatplotLibAPI-3.2.5.dist-info → MatplotLibAPI-3.2.8.dist-info}/WHEEL +0 -0
- {MatplotLibAPI-3.2.5.dist-info → MatplotLibAPI-3.2.8.dist-info}/top_level.txt +0 -0
MatplotLibAPI/Composite.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# Hint for Visual Code Python Interactive window
|
|
2
2
|
# %%
|
|
3
|
-
from typing import Optional, Tuple,List
|
|
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
|
-
|
|
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
|
|
11
|
+
from .Treemap import aplot_treemap, TREEMAP_STYLE_TEMPLATE
|
|
12
12
|
from .StyleTemplate import StyleTemplate, format_func, validate_dataframe
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
def plot_composite_bubble(
|
|
17
16
|
pd_df: pd.DataFrame,
|
|
18
17
|
label: str,
|
|
@@ -44,17 +43,17 @@ def plot_composite_bubble(
|
|
|
44
43
|
grid = plt.GridSpec(2, 2, height_ratios=[2, 1], width_ratios=[1, 1])
|
|
45
44
|
ax = fig.add_subplot(grid[0, 0:])
|
|
46
45
|
ax = aplot_bubble(pd_df=plot_df,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
label=label,
|
|
47
|
+
x=x,
|
|
48
|
+
y=y,
|
|
49
|
+
z=z,
|
|
50
|
+
title=title,
|
|
51
|
+
style=style,
|
|
52
|
+
max_values=max_values,
|
|
53
|
+
center_to_mean=center_to_mean,
|
|
54
|
+
sort_by=sort_by,
|
|
55
|
+
ascending=ascending,
|
|
56
|
+
ax=ax)
|
|
58
57
|
|
|
59
58
|
if "label" in style.format_funcs:
|
|
60
59
|
style.format_funcs[label] = style.format_funcs["label"]
|
|
@@ -90,3 +89,36 @@ def plot_composite_bubble(
|
|
|
90
89
|
fig.tight_layout()
|
|
91
90
|
return fig
|
|
92
91
|
|
|
92
|
+
|
|
93
|
+
def plot_composite_treemap(pd_dfs: List[pd.DataFrame],
|
|
94
|
+
path: str,
|
|
95
|
+
values: str,
|
|
96
|
+
style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
|
|
97
|
+
title: Optional[str] = None,
|
|
98
|
+
color: Optional[str] = None,
|
|
99
|
+
sort_by: Optional[str] = None,
|
|
100
|
+
ascending: bool = False,
|
|
101
|
+
max_values: int = 100) -> go.Figure:
|
|
102
|
+
|
|
103
|
+
num_dimensions = len(pd_dfs)
|
|
104
|
+
if num_dimensions > 0:
|
|
105
|
+
fig = make_subplots(
|
|
106
|
+
rows=num_dimensions,
|
|
107
|
+
cols=1,
|
|
108
|
+
specs=[[{'type': 'domain'}] for _ in range(num_dimensions)],
|
|
109
|
+
vertical_spacing=0.02
|
|
110
|
+
)
|
|
111
|
+
current_row = 1
|
|
112
|
+
for pd_df in pd_dfs:
|
|
113
|
+
trm = aplot_treemap(pd_df=pd_df,
|
|
114
|
+
path=path,
|
|
115
|
+
values=values,
|
|
116
|
+
title=title,
|
|
117
|
+
style=style,
|
|
118
|
+
color=color,
|
|
119
|
+
sort_by=sort_by,
|
|
120
|
+
ascending=ascending,
|
|
121
|
+
max_values=max_values)
|
|
122
|
+
fig.add_trace(trm,row=current_row, col=1)
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
@@ -106,13 +106,13 @@ class DataFrameAccessor:
|
|
|
106
106
|
ascending=ascending)
|
|
107
107
|
|
|
108
108
|
def aplot_table(self,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
116
|
|
|
117
117
|
return aplot_table(pd_df=self._obj,
|
|
118
118
|
cols=cols,
|
|
@@ -259,19 +259,41 @@ class DataFrameAccessor:
|
|
|
259
259
|
style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
|
|
260
260
|
title: Optional[str] = None,
|
|
261
261
|
color: Optional[str] = None,
|
|
262
|
-
max_values: int = 100,
|
|
263
262
|
sort_by: Optional[str] = None,
|
|
264
|
-
|
|
263
|
+
max_values: int = 100,
|
|
264
|
+
ascending: bool = False,
|
|
265
|
+
fig: Optional[go.Figure] = None) -> go.Figure:
|
|
265
266
|
return fplot_treemap(pd_df=self._obj,
|
|
266
267
|
path=path,
|
|
267
268
|
values=values,
|
|
268
269
|
title=title,
|
|
269
270
|
style=style,
|
|
270
271
|
color=color,
|
|
272
|
+
sort_by=sort_by,
|
|
273
|
+
ascending=ascending,
|
|
271
274
|
max_values=max_values,
|
|
275
|
+
fig=fig)
|
|
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,
|
|
272
293
|
sort_by=sort_by,
|
|
273
|
-
ascending=ascending
|
|
294
|
+
ascending=ascending,
|
|
295
|
+
max_values=max_values)
|
|
274
296
|
|
|
275
297
|
|
|
276
298
|
__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"]
|
|
299
|
+
"plot_pivotbar", "fplot_treemap", "aplot_treemap", "plot_composite_bubble", "StyleTemplate", "DataFrameAccessor"]
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
MatplotLibAPI/Bubble.py,sha256=ZtOTWGAnJ1zy7bjKQ3OF985R-iZHvZOo_rG1dZMbP-Q,5116
|
|
2
|
-
MatplotLibAPI/Composite.py,sha256=
|
|
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=
|
|
9
|
-
MatplotLibAPI/__init__.py,sha256
|
|
10
|
-
MatplotLibAPI-3.2.
|
|
11
|
-
MatplotLibAPI-3.2.
|
|
12
|
-
MatplotLibAPI-3.2.
|
|
13
|
-
MatplotLibAPI-3.2.
|
|
14
|
-
MatplotLibAPI-3.2.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|