MatplotLibAPI 3.0.4__py3-none-any.whl → 3.0.5__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/Bubble.py +1 -3
- MatplotLibAPI/Composite.py +14 -5
- MatplotLibAPI/Treemap.py +59 -0
- MatplotLibAPI/__init__.py +2 -1
- MatplotLibAPI/pdAccessor.py +29 -7
- {MatplotLibAPI-3.0.4.dist-info → MatplotLibAPI-3.0.5.dist-info}/METADATA +2 -1
- MatplotLibAPI-3.0.5.dist-info/RECORD +15 -0
- MatplotLibAPI-3.0.4.dist-info/RECORD +0 -14
- {MatplotLibAPI-3.0.4.dist-info → MatplotLibAPI-3.0.5.dist-info}/LICENSE +0 -0
- {MatplotLibAPI-3.0.4.dist-info → MatplotLibAPI-3.0.5.dist-info}/WHEEL +0 -0
- {MatplotLibAPI-3.0.4.dist-info → MatplotLibAPI-3.0.5.dist-info}/top_level.txt +0 -0
MatplotLibAPI/Bubble.py
CHANGED
MatplotLibAPI/Composite.py
CHANGED
|
@@ -6,7 +6,7 @@ import pandas as pd
|
|
|
6
6
|
from .Bubble import plot_bubble, BUBBLE_STYLE_TEMPLATE
|
|
7
7
|
from .Table import plot_table
|
|
8
8
|
from typing import Optional, Tuple
|
|
9
|
-
from .Style import StyleTemplate, _validate_panda,format_func
|
|
9
|
+
from .Style import StyleTemplate, _validate_panda, format_func
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def plot_composite_bubble(
|
|
@@ -19,18 +19,27 @@ def plot_composite_bubble(
|
|
|
19
19
|
style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
|
|
20
20
|
max_values: int = 50,
|
|
21
21
|
center_to_mean: bool = False,
|
|
22
|
+
filter_by:Optional[str] = None,
|
|
22
23
|
sort_by: Optional[str] = None,
|
|
23
24
|
ascending: bool = False,
|
|
24
25
|
table_rows: int = 10,
|
|
25
26
|
figsize: Tuple[float, float] = (19.2, 10.8)) -> Figure:
|
|
26
27
|
|
|
27
28
|
_validate_panda(pd_df, cols=[label, x, y, z], sort_by=sort_by)
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
if not sort_by:
|
|
31
|
+
sort_by = z
|
|
32
|
+
if not filter_by:
|
|
33
|
+
filter_by = z
|
|
34
|
+
plot_df = pd_df.sort_values(by=filter_by,
|
|
35
|
+
ascending=ascending)[[label, x, y, z]].head(max_values)
|
|
36
|
+
style.format_funcs = format_func(
|
|
37
|
+
style.format_funcs, label=label, x=x, y=y, z=z)
|
|
29
38
|
fig = plt.figure(figsize=figsize)
|
|
30
39
|
fig.patch.set_facecolor("black")
|
|
31
40
|
grid = plt.GridSpec(2, 2, height_ratios=[2, 1], width_ratios=[1, 1])
|
|
32
41
|
ax = fig.add_subplot(grid[0, 0:])
|
|
33
|
-
ax = plot_bubble(pd_df=
|
|
42
|
+
ax = plot_bubble(pd_df=plot_df,
|
|
34
43
|
label=label,
|
|
35
44
|
x=x,
|
|
36
45
|
y=y,
|
|
@@ -54,7 +63,7 @@ def plot_composite_bubble(
|
|
|
54
63
|
|
|
55
64
|
ax2 = fig.add_subplot(grid[1, 0])
|
|
56
65
|
ax2 = plot_table(
|
|
57
|
-
pd_df=
|
|
66
|
+
pd_df=plot_df,
|
|
58
67
|
cols=[label, z, y, x],
|
|
59
68
|
title=f"Top {table_rows}",
|
|
60
69
|
ax=ax2,
|
|
@@ -65,7 +74,7 @@ def plot_composite_bubble(
|
|
|
65
74
|
)
|
|
66
75
|
ax3 = fig.add_subplot(grid[1, 1])
|
|
67
76
|
ax3 = plot_table(
|
|
68
|
-
pd_df=
|
|
77
|
+
pd_df=plot_df,
|
|
69
78
|
cols=[label, z, y, x],
|
|
70
79
|
title=f"Worst {table_rows}",
|
|
71
80
|
ax=ax3,
|
MatplotLibAPI/Treemap.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import plotly.graph_objects as go
|
|
4
|
+
from .Style import DynamicFuncFormatter, StyleTemplate, generate_ticks, string_formatter, _validate_panda, percent_formatter, format_func
|
|
5
|
+
|
|
6
|
+
TREEMAP_STYLE_TEMPLATE = StyleTemplate(
|
|
7
|
+
background_color='black',
|
|
8
|
+
fig_border='darkgrey',
|
|
9
|
+
font_color='white',
|
|
10
|
+
palette='magma',
|
|
11
|
+
format_funcs={"y": percent_formatter,
|
|
12
|
+
"label": string_formatter}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def plot_treemap(pd_df: pd.DataFrame,
|
|
17
|
+
path: str,
|
|
18
|
+
values: str,
|
|
19
|
+
style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
|
|
20
|
+
title: Optional[str] = None,
|
|
21
|
+
color: Optional[str] = None,
|
|
22
|
+
sort_by: Optional[str] = None,
|
|
23
|
+
ascending: bool = False,
|
|
24
|
+
max_values: int = 100,
|
|
25
|
+
fig: Optional[go.Figure] = None) -> go.Figure:
|
|
26
|
+
cols = [path, values]
|
|
27
|
+
if color:
|
|
28
|
+
cols.append(color)
|
|
29
|
+
_validate_panda(df, cols=cols, sort_by=sort_by)
|
|
30
|
+
if not sort_by:
|
|
31
|
+
sort_by = values
|
|
32
|
+
df = pd_df.sort_values(by=sort_by, ascending=ascending)[
|
|
33
|
+
cols].head(max_values)
|
|
34
|
+
data = {"labels": df[path],
|
|
35
|
+
"parents": [""] * len(df),
|
|
36
|
+
"values": df[values],
|
|
37
|
+
"textinfo": "label",
|
|
38
|
+
"name": title}
|
|
39
|
+
|
|
40
|
+
if color:
|
|
41
|
+
df['color'] = df[color]
|
|
42
|
+
|
|
43
|
+
if not fig:
|
|
44
|
+
fig = go.Figure(data=data)
|
|
45
|
+
else:
|
|
46
|
+
fig.add_trace(go.Treemap(data))
|
|
47
|
+
|
|
48
|
+
fig.update_layout(
|
|
49
|
+
paper_bgcolor=style.background_color,
|
|
50
|
+
plot_bgcolor=style.background_color,
|
|
51
|
+
font=dict(color=style.font_color),
|
|
52
|
+
margin=dict(t=50, l=25, r=25, b=25))
|
|
53
|
+
|
|
54
|
+
# Apply color scale
|
|
55
|
+
fig.update_traces(
|
|
56
|
+
marker=dict(colorscale=style.palette)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return fig
|
MatplotLibAPI/__init__.py
CHANGED
|
@@ -5,9 +5,10 @@ from .Timeserie import plot_timeserie
|
|
|
5
5
|
from .Bubble import plot_bubble
|
|
6
6
|
from .Network import plot_network
|
|
7
7
|
from .Pivot import plot_pivotbar
|
|
8
|
+
from .Treemap import plot_treemap
|
|
8
9
|
from .Composite import plot_composite_bubble
|
|
9
10
|
from .pdAccessor import MatPlotLibAccessor
|
|
10
11
|
from .Style import StyleTemplate
|
|
11
12
|
|
|
12
13
|
__all__ = ["plot_bubble", "plot_timeserie", "plot_table", "plot_network",
|
|
13
|
-
"plot_pivotbar", "plot_composite_bubble", "StyleTemplate", "MatPlotLibAccessor"]
|
|
14
|
+
"plot_pivotbar", "plot_treemap","plot_composite_bubble", "StyleTemplate", "MatPlotLibAccessor"]
|
MatplotLibAPI/pdAccessor.py
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
import logging
|
|
3
3
|
import warnings
|
|
4
|
+
|
|
4
5
|
from typing import Optional, List
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
5
8
|
from matplotlib.axes import Axes
|
|
6
9
|
from matplotlib.figure import Figure
|
|
7
|
-
import
|
|
10
|
+
import plotly.graph_objects as go
|
|
8
11
|
from .Style import StyleTemplate
|
|
9
12
|
from .Bubble import plot_bubble, BUBBLE_STYLE_TEMPLATE
|
|
10
13
|
from .Composite import plot_composite_bubble
|
|
11
14
|
from .Timeserie import plot_timeserie, TIMESERIE_STYLE_TEMPLATE
|
|
12
15
|
from .Table import plot_table, TABLE_STYLE_TEMPLATE
|
|
13
|
-
from .Network import
|
|
14
|
-
|
|
16
|
+
from .Network import Graph
|
|
17
|
+
from .Treemap import plot_treemap, TREEMAP_STYLE_TEMPLATE
|
|
15
18
|
|
|
16
19
|
warnings.filterwarnings('ignore')
|
|
17
20
|
logging.getLogger().setLevel(logging.WARNING)
|
|
@@ -28,7 +31,7 @@ class MatPlotLibAccessor:
|
|
|
28
31
|
x: str,
|
|
29
32
|
y: str,
|
|
30
33
|
z: str,
|
|
31
|
-
title: str =
|
|
34
|
+
title: Optional[str] = None,
|
|
32
35
|
style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
|
|
33
36
|
max_values: int = 50,
|
|
34
37
|
center_to_mean: bool = False,
|
|
@@ -47,14 +50,14 @@ class MatPlotLibAccessor:
|
|
|
47
50
|
sort_by=sort_by,
|
|
48
51
|
ascending=ascending)
|
|
49
52
|
|
|
50
|
-
def
|
|
53
|
+
def plot_composite_bubble(self,
|
|
51
54
|
label: str,
|
|
52
55
|
x: str,
|
|
53
56
|
y: str,
|
|
54
57
|
z: str,
|
|
55
58
|
title: Optional[str] = None,
|
|
56
59
|
style: StyleTemplate = BUBBLE_STYLE_TEMPLATE,
|
|
57
|
-
max_values: int =
|
|
60
|
+
max_values: int = 100,
|
|
58
61
|
center_to_mean: bool = False,
|
|
59
62
|
sort_by: Optional[str] = None,
|
|
60
63
|
ascending: bool = False) -> Figure:
|
|
@@ -93,7 +96,7 @@ class MatPlotLibAccessor:
|
|
|
93
96
|
y: str,
|
|
94
97
|
title: Optional[str] = None,
|
|
95
98
|
style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
|
|
96
|
-
max_values: int =
|
|
99
|
+
max_values: int = 100,
|
|
97
100
|
sort_by: Optional[str] = None,
|
|
98
101
|
ascending: bool = False) -> Axes:
|
|
99
102
|
|
|
@@ -123,3 +126,22 @@ class MatPlotLibAccessor:
|
|
|
123
126
|
weight=weight)
|
|
124
127
|
|
|
125
128
|
return graph.plotX(title, style)
|
|
129
|
+
|
|
130
|
+
def plot_treemap(self,
|
|
131
|
+
path: str,
|
|
132
|
+
values: str,
|
|
133
|
+
style: StyleTemplate = TREEMAP_STYLE_TEMPLATE,
|
|
134
|
+
title: Optional[str] = None,
|
|
135
|
+
color: Optional[str] = None,
|
|
136
|
+
max_values: int = 100,
|
|
137
|
+
sort_by: Optional[str] = None,
|
|
138
|
+
ascending: bool = False) ->go.Figure:
|
|
139
|
+
return plot_treemap(pd_df=self._obj,
|
|
140
|
+
path=path,
|
|
141
|
+
values=values,
|
|
142
|
+
title=title,
|
|
143
|
+
style=style,
|
|
144
|
+
color=color,
|
|
145
|
+
max_values=max_values,
|
|
146
|
+
sort_by=sort_by,
|
|
147
|
+
ascending=ascending)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: MatplotLibAPI
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.5
|
|
4
4
|
Requires-Python: >=3.7
|
|
5
5
|
Description-Content-Type: text/markdown
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Requires-Dist: pandas
|
|
8
8
|
Requires-Dist: matplotlib
|
|
9
9
|
Requires-Dist: networkx
|
|
10
|
+
Requires-Dist: plotly
|
|
10
11
|
Requires-Dist: seaborn
|
|
11
12
|
Requires-Dist: scikit-learn
|
|
12
13
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
MatplotLibAPI/Bubble.py,sha256=2PIwL0stzFC7knqdMHBBm99DXPXtBJK-xmpxmVlInYw,3830
|
|
2
|
+
MatplotLibAPI/Composite.py,sha256=M_AaBdn9cfMIOGZBg4_twRS9VU9jbgS6cs9E5l3ObOQ,2763
|
|
3
|
+
MatplotLibAPI/Network.py,sha256=fq1-LfDKy3oC5JzqU7IyZudgR2plmziigjpm2TzEA3U,13286
|
|
4
|
+
MatplotLibAPI/Pivot.py,sha256=8jRYdlvw8otrJ1hYBAaKQJoN84xe-YfroXmgRLykMmQ,7162
|
|
5
|
+
MatplotLibAPI/Style.py,sha256=xtw71VWHSQEvts1nJdKR0c_9Rqef6EGkyyvgdTK5M7c,4632
|
|
6
|
+
MatplotLibAPI/Table.py,sha256=Az5uX-ViqzJPTBym4QnUzn5PD5LEsVzQ9WohcSDFcK4,1990
|
|
7
|
+
MatplotLibAPI/Timeserie.py,sha256=HRFHs_WzaZzLmWVVMBKVMP5M3oglsr1R9Ni53X7_HLI,3432
|
|
8
|
+
MatplotLibAPI/Treemap.py,sha256=diCx5270ENBObO3eWlLlpaHWUWcSgMT34vEwWTxTDAE,1799
|
|
9
|
+
MatplotLibAPI/__init__.py,sha256=PDobJg0sw7BjgSQk7p7kkjombghs3D_m-CCk2oeUt_s,506
|
|
10
|
+
MatplotLibAPI/pdAccessor.py,sha256=5duWsURQKgNuwCz1p0ge2GbAXHSHl8e38zJn6NSVAGg,5745
|
|
11
|
+
MatplotLibAPI-3.0.5.dist-info/LICENSE,sha256=hMErKLb6YZR3lRR5zr-vxeFkvY69QAaafgSpZ5-P1dQ,1067
|
|
12
|
+
MatplotLibAPI-3.0.5.dist-info/METADATA,sha256=icSnJdKd4E6mw4SKUPaTHg9QgsWfUiiRvMlrQUXAz10,319
|
|
13
|
+
MatplotLibAPI-3.0.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
14
|
+
MatplotLibAPI-3.0.5.dist-info/top_level.txt,sha256=MrzbBjDEW48Vb6YhQIqpFYGOhHzQnEIM5Qy2xy2iqew,14
|
|
15
|
+
MatplotLibAPI-3.0.5.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
MatplotLibAPI/Bubble.py,sha256=aYw8qcYF_cXJzAU7tIi5Cn7Y-sRfR8Cvm5RivMvVd5E,3860
|
|
2
|
-
MatplotLibAPI/Composite.py,sha256=1qP_9TEz58EDA-oEev21WfJh2mxAEVVkRqYsysvMw7E,2478
|
|
3
|
-
MatplotLibAPI/Network.py,sha256=fq1-LfDKy3oC5JzqU7IyZudgR2plmziigjpm2TzEA3U,13286
|
|
4
|
-
MatplotLibAPI/Pivot.py,sha256=8jRYdlvw8otrJ1hYBAaKQJoN84xe-YfroXmgRLykMmQ,7162
|
|
5
|
-
MatplotLibAPI/Style.py,sha256=xtw71VWHSQEvts1nJdKR0c_9Rqef6EGkyyvgdTK5M7c,4632
|
|
6
|
-
MatplotLibAPI/Table.py,sha256=Az5uX-ViqzJPTBym4QnUzn5PD5LEsVzQ9WohcSDFcK4,1990
|
|
7
|
-
MatplotLibAPI/Timeserie.py,sha256=HRFHs_WzaZzLmWVVMBKVMP5M3oglsr1R9Ni53X7_HLI,3432
|
|
8
|
-
MatplotLibAPI/__init__.py,sha256=-i49Ta56gER88f6R_BDOo-JiLc5UUGvxHg2aHdJv0PQ,457
|
|
9
|
-
MatplotLibAPI/pdAccessor.py,sha256=7R4QoZDHFkf67rn1zDxJMkghQa-BUPu6Fy7TXVT9-OQ,4844
|
|
10
|
-
MatplotLibAPI-3.0.4.dist-info/LICENSE,sha256=hMErKLb6YZR3lRR5zr-vxeFkvY69QAaafgSpZ5-P1dQ,1067
|
|
11
|
-
MatplotLibAPI-3.0.4.dist-info/METADATA,sha256=spXzV0K_jdy4D5-4oi4plFlFaltrVQRjtsJUXbbCH90,297
|
|
12
|
-
MatplotLibAPI-3.0.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
13
|
-
MatplotLibAPI-3.0.4.dist-info/top_level.txt,sha256=MrzbBjDEW48Vb6YhQIqpFYGOhHzQnEIM5Qy2xy2iqew,14
|
|
14
|
-
MatplotLibAPI-3.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|