MatplotLibAPI 3.0.2__tar.gz → 3.1.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 (22) hide show
  1. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Bubble.py +1 -3
  2. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Composite.py +14 -5
  3. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Timeserie.py +3 -4
  4. matplotlibapi-3.1.0/MatplotLibAPI/Treemap.py +59 -0
  5. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/__init__.py +2 -1
  6. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/pdAccessor.py +45 -23
  7. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI.egg-info/PKG-INFO +4 -2
  8. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI.egg-info/SOURCES.txt +1 -1
  9. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI.egg-info/requires.txt +2 -1
  10. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/PKG-INFO +4 -2
  11. matplotlibapi-3.1.0/pyproject.toml +11 -0
  12. matplotlibapi-3.0.2/pyproject.toml +0 -3
  13. matplotlibapi-3.0.2/setup.py +0 -19
  14. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/LICENSE +0 -0
  15. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Network.py +0 -0
  16. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Pivot.py +0 -0
  17. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Style.py +0 -0
  18. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI/Table.py +0 -0
  19. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI.egg-info/dependency_links.txt +0 -0
  20. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/MatplotLibAPI.egg-info/top_level.txt +0 -0
  21. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/README.md +0 -0
  22. {matplotlibapi-3.0.2 → matplotlibapi-3.1.0}/setup.cfg +0 -0
@@ -15,9 +15,7 @@ BUBBLE_STYLE_TEMPLATE = StyleTemplate(
15
15
  "y": percent_formatter,
16
16
  "label": string_formatter,
17
17
  "z": bmk_formatter},
18
- yscale="log",
19
- y_ticks=8,
20
- x_ticks=8
18
+ yscale="log"
21
19
  )
22
20
 
23
21
 
@@ -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
- style.format_funcs=format_func(style.format_funcs,label=label,x=x,y=y)
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=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=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=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,
@@ -5,7 +5,7 @@ import pandas as pd
5
5
  import matplotlib.pyplot as plt
6
6
  from matplotlib.axes import Axes
7
7
  import seaborn as sns
8
- from .Style import DynamicFuncFormatter, StyleTemplate, string_formatter, _validate_panda, bmk_formatter,format_func
8
+ from .Style import DynamicFuncFormatter, StyleTemplate, string_formatter, _validate_panda, bmk_formatter, format_func
9
9
  from typing import Optional
10
10
 
11
11
  TIMESERIE_STYLE_TEMPLATE = StyleTemplate(
@@ -15,20 +15,19 @@ TIMESERIE_STYLE_TEMPLATE = StyleTemplate(
15
15
 
16
16
  # region Line
17
17
 
18
-
19
18
  def plot_timeserie(pd_df: pd.DataFrame,
20
19
  label: str,
21
20
  x: str,
22
21
  y: str,
23
22
  title: Optional[str] = None,
24
23
  style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
24
+ max_values: int = 100,
25
25
  sort_by: Optional[str] = None,
26
26
  ascending: bool = False,
27
27
  ax: Optional[Axes] = None) -> Axes:
28
28
 
29
29
  _validate_panda(pd_df, cols=[label, x, y], sort_by=sort_by)
30
- style.format_funcs=format_func(style.format_funcs,label=label,x=x,y=y)
31
-
30
+ style.format_funcs = format_func(style.format_funcs, label=label, x=x, y=y)
32
31
 
33
32
  df = pd_df[[label, x, y]].sort_values(by=[label, x])
34
33
  df[x] = pd.to_datetime(df[x])
@@ -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
@@ -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"]
@@ -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 pandas as pd
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
- from .Timeserie import plot_timeserie,TIMESERIE_STYLE_TEMPLATE
14
+ from .Timeserie import plot_timeserie, TIMESERIE_STYLE_TEMPLATE
12
15
  from .Table import plot_table, TABLE_STYLE_TEMPLATE
13
- from .Network import (Graph)
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 = "Test",
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 plot_bubble_composite(self,
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 = 50,
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:
@@ -88,24 +91,24 @@ class MatPlotLibAccessor:
88
91
  ascending=ascending)
89
92
 
90
93
  def plot_timeserie(self,
91
- label: str,
92
- x: str,
93
- y: str,
94
- title: Optional[str] = None,
95
- style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
96
- max_values: int = 20,
97
- sort_by: Optional[str] = None,
98
- ascending: bool = False) -> Axes:
94
+ label: str,
95
+ x: str,
96
+ y: str,
97
+ title: Optional[str] = None,
98
+ style: StyleTemplate = TIMESERIE_STYLE_TEMPLATE,
99
+ max_values: int = 100,
100
+ sort_by: Optional[str] = None,
101
+ ascending: bool = False) -> Axes:
99
102
 
100
103
  return plot_timeserie(pd_df=self._obj,
101
- label=label,
102
- x=x,
103
- y=y,
104
- title=title,
105
- style=style,
106
- max_values=max_values,
107
- sort_by=sort_by,
108
- ascending=ascending)
104
+ label=label,
105
+ x=x,
106
+ y=y,
107
+ title=title,
108
+ style=style,
109
+ max_values=max_values,
110
+ sort_by=sort_by,
111
+ ascending=ascending)
109
112
 
110
113
  def plot_network(self,
111
114
  source: str = "source",
@@ -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,13 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.0.2
3
+ Version: 3.1.0
4
+ Requires-Python: >=3.7
4
5
  Description-Content-Type: text/markdown
5
6
  License-File: LICENSE
6
7
  Requires-Dist: pandas
7
8
  Requires-Dist: matplotlib
9
+ Requires-Dist: networkx
10
+ Requires-Dist: plotly
8
11
  Requires-Dist: seaborn
9
12
  Requires-Dist: scikit-learn
10
- Requires-Dist: networkx
11
13
 
12
14
  # MatplotLibAPI
13
15
  Simple Wrapper
@@ -1,7 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- setup.py
5
4
  MatplotLibAPI/Bubble.py
6
5
  MatplotLibAPI/Composite.py
7
6
  MatplotLibAPI/Network.py
@@ -9,6 +8,7 @@ MatplotLibAPI/Pivot.py
9
8
  MatplotLibAPI/Style.py
10
9
  MatplotLibAPI/Table.py
11
10
  MatplotLibAPI/Timeserie.py
11
+ MatplotLibAPI/Treemap.py
12
12
  MatplotLibAPI/__init__.py
13
13
  MatplotLibAPI/pdAccessor.py
14
14
  MatplotLibAPI.egg-info/PKG-INFO
@@ -1,5 +1,6 @@
1
1
  pandas
2
2
  matplotlib
3
+ networkx
4
+ plotly
3
5
  seaborn
4
6
  scikit-learn
5
- networkx
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MatplotLibAPI
3
- Version: 3.0.2
3
+ Version: 3.1.0
4
+ Requires-Python: >=3.7
4
5
  Description-Content-Type: text/markdown
5
6
  License-File: LICENSE
6
7
  Requires-Dist: pandas
7
8
  Requires-Dist: matplotlib
9
+ Requires-Dist: networkx
10
+ Requires-Dist: plotly
8
11
  Requires-Dist: seaborn
9
12
  Requires-Dist: scikit-learn
10
- Requires-Dist: networkx
11
13
 
12
14
  # MatplotLibAPI
13
15
  Simple Wrapper
@@ -0,0 +1,11 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+ [project]
5
+ name = "MatplotLibAPI"
6
+ version="v3.1.0"
7
+ readme = "README.md"
8
+ requires-python=">=3.7"
9
+ dependencies = ["pandas","matplotlib","networkx","plotly","seaborn","scikit-learn",]
10
+
11
+
@@ -1,3 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools", "wheel"]
3
- build-backend = "setuptools.build_meta"
@@ -1,19 +0,0 @@
1
- import os
2
- from setuptools import setup, find_packages
3
-
4
- requirements = []
5
- requirements_file = 'requirements.txt'
6
-
7
- # Check if the file exists
8
- if os.path.exists(requirements_file):
9
- with open(requirements_file) as f:
10
- requirements = f.read().splitlines()
11
-
12
- setup(
13
- name='MatplotLibAPI',
14
- version='v3.0.2',
15
- packages=find_packages(),
16
- install_requires=requirements,
17
- long_description=open('README.md').read(),
18
- long_description_content_type='text/markdown',
19
- )
File without changes
File without changes
File without changes