plotly-extend-wrapper 1.3.0__tar.gz → 1.5.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 (42) hide show
  1. plotly_extend_wrapper-1.5.0/PKG-INFO +117 -0
  2. plotly_extend_wrapper-1.5.0/README.md +99 -0
  3. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper/__init__.py +10 -0
  4. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper/common.py +22 -0
  5. {plotly_extend_wrapper-1.3.0 → plotly_extend_wrapper-1.5.0}/plotly_extend_wrapper/wrapper.py +81 -16
  6. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper.egg-info/PKG-INFO +117 -0
  7. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper.egg-info/SOURCES.txt +17 -0
  8. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper.egg-info/dependency_links.txt +1 -0
  9. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper.egg-info/requires.txt +10 -0
  10. plotly_extend_wrapper-1.5.0/plotly_extend_wrapper.egg-info/top_level.txt +1 -0
  11. plotly_extend_wrapper-1.5.0/pyproject.toml +33 -0
  12. plotly_extend_wrapper-1.5.0/setup.cfg +4 -0
  13. plotly_extend_wrapper-1.5.0/test/test_common.py +56 -0
  14. {plotly_extend_wrapper-1.3.0 → plotly_extend_wrapper-1.5.0}/test/test_updater.py +52 -1
  15. plotly_extend_wrapper-1.5.0/test/test_version.py +30 -0
  16. {plotly_extend_wrapper-1.3.0 → plotly_extend_wrapper-1.5.0}/test/test_wrapper.py +187 -0
  17. plotly_extend_wrapper-1.5.0/test/test_wrapper_polars.py +291 -0
  18. plotly_extend_wrapper-1.3.0/.devcontainer/devcontainer.json +0 -29
  19. plotly_extend_wrapper-1.3.0/.github/dependabot.yml +0 -12
  20. plotly_extend_wrapper-1.3.0/.github/workflows/deploy_pages.yaml +0 -34
  21. plotly_extend_wrapper-1.3.0/.github/workflows/pypi_release.yml +0 -29
  22. plotly_extend_wrapper-1.3.0/.github/workflows/unittest.yml +0 -26
  23. plotly_extend_wrapper-1.3.0/.gitignore +0 -159
  24. plotly_extend_wrapper-1.3.0/.python-version +0 -1
  25. plotly_extend_wrapper-1.3.0/.vscode/settings.json +0 -10
  26. plotly_extend_wrapper-1.3.0/PKG-INFO +0 -39
  27. plotly_extend_wrapper-1.3.0/README.md +0 -24
  28. plotly_extend_wrapper-1.3.0/codecov.yaml +0 -13
  29. plotly_extend_wrapper-1.3.0/docs/Makefile +0 -20
  30. plotly_extend_wrapper-1.3.0/docs/conf.py +0 -31
  31. plotly_extend_wrapper-1.3.0/docs/index.rst +0 -49
  32. plotly_extend_wrapper-1.3.0/docs/make.bat +0 -35
  33. plotly_extend_wrapper-1.3.0/docs/source/introduction.md +0 -1
  34. plotly_extend_wrapper-1.3.0/docs/source/wrapper.md +0 -49
  35. plotly_extend_wrapper-1.3.0/plotly_extend_wrapper/__init__.py +0 -5
  36. plotly_extend_wrapper-1.3.0/plotly_extend_wrapper/common.py +0 -12
  37. plotly_extend_wrapper-1.3.0/pyproject.toml +0 -41
  38. plotly_extend_wrapper-1.3.0/requirements-dev.lock +0 -266
  39. plotly_extend_wrapper-1.3.0/requirements.lock +0 -63
  40. plotly_extend_wrapper-1.3.0/test/test_common.py +0 -25
  41. {plotly_extend_wrapper-1.3.0 → plotly_extend_wrapper-1.5.0}/LICENSE +0 -0
  42. {plotly_extend_wrapper-1.3.0 → plotly_extend_wrapper-1.5.0}/plotly_extend_wrapper/updater.py +0 -0
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: plotly-extend-wrapper
3
+ Version: 1.5.0
4
+ Author-email: Laplusdestiny <prayonshootingstars@gmail.com>
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: plotly>=6.1.0
9
+ Requires-Dist: kaleido>=0.2.1
10
+ Requires-Dist: pyarrow>=10.0.0
11
+ Requires-Dist: pandas>=2.0.0
12
+ Requires-Dist: scipy>=1.8.0
13
+ Requires-Dist: numpy>=1.24.0
14
+ Requires-Dist: nbformat>=4.2.0
15
+ Provides-Extra: polars
16
+ Requires-Dist: polars>=0.20.0; extra == "polars"
17
+ Dynamic: license-file
18
+
19
+ # plotly_extend_wrapper
20
+
21
+ [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Laplusdestiny/plotly_extend_wrapper/main?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/commits/main/)
22
+ [![Codecov](https://img.shields.io/codecov/c/gh/Laplusdestiny/plotly_extend_wrapper?style=flat&logo=codecov)](https://app.codecov.io/gh/Laplusdestiny/plotly_extend_wrapper)
23
+ [![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/releases)
24
+ [![PyPI - Version](https://img.shields.io/pypi/v/plotly_extend_wrapper?logo=pypi)](https://pypi.org/project/plotly-extend-wrapper/)
25
+
26
+ Extended Python library for Plotly
27
+
28
+ - **Simple Interface**: Create complex visualizations with just a few lines of code
29
+ - **pandas / polars Support**: Accepts `pandas.DataFrame`, `polars.DataFrame` and `polars.LazyFrame`
30
+ - **Automated Preprocessing**: Value counting, rounding and pivoting are handled for you
31
+ - **Multiple Plot Types**: Pie, sunburst, bubble, line (with secondary y-axis), and 3D surface charts
32
+ - **Customization**: Update titles, legend, size and markers through a unified interface
33
+
34
+ For detailed documentation and examples, visit our [Documentation](https://laplusdestiny.github.io/plotly_extend_wrapper/)
35
+
36
+ ## Install
37
+
38
+ ``` bash
39
+ pip install plotly-extend-wrapper
40
+
41
+ # with polars support
42
+ pip install "plotly-extend-wrapper[polars]"
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ``` python
48
+ import pandas as pd
49
+ from plotly_extend_wrapper import Plot_pie, Plot_line, Update_plotly_object
50
+
51
+ df = pd.DataFrame({"category": ["A", "B", "A", "C", "B"]})
52
+ fig = Plot_pie(df, "category") # value counts are computed automatically
53
+
54
+ df = pd.DataFrame({
55
+ "date": pd.date_range("2024-01-01", periods=100, freq="D"),
56
+ "sales": range(100),
57
+ "temperature": [i % 30 for i in range(100)],
58
+ })
59
+ fig = Plot_line(
60
+ df,
61
+ x="date",
62
+ y=["sales"],
63
+ secondary_y=["temperature"],
64
+ ytitle="Sales",
65
+ secondary_ytitle="Temperature",
66
+ vline=["2024-02-01"],
67
+ )
68
+
69
+ updater = Update_plotly_object(fig)
70
+ updater.update(height=500, width=900, legend_position="h")
71
+ updater.write_image("output/line.png")
72
+ ```
73
+
74
+ ## Supported Functions
75
+
76
+ | Name | Description |
77
+ | --- | --- |
78
+ | `Plot_pie` | Pie chart from the value counts of a column |
79
+ | `Plot_sunburst` | Hierarchical sunburst chart from the value counts of multiple columns |
80
+ | `Plot_bubble_chart` | Bubble chart whose size is the frequency of (x, y) pairs |
81
+ | `Plot_bubble_chart_with_line` | Overlay linear lines (`y = a * x + b`) on a bubble chart |
82
+ | `Plot_line` | Line chart with secondary y-axis, highlighted periods and vertical lines |
83
+ | `Plot_surface` | 3D surface plot with optional cubic interpolation |
84
+ | `Update_plotly_object` | Update layout of an existing figure and export it as an image |
85
+ | `check_directory` | Create parent directories for an output path |
86
+
87
+ ## Requirement
88
+
89
+ - Python >= 3.9
90
+ - plotly >= 6.1.0
91
+ - kaleido >= 0.2.1
92
+ - pandas >= 2.0.0
93
+ - pyarrow >= 10.0.0
94
+ - numpy >= 1.24.0
95
+ - scipy >= 1.8.0
96
+ - nbformat >= 4.2.0
97
+ - polars >= 0.20.0 (optional)
98
+
99
+ ## Development
100
+
101
+ ``` bash
102
+ uv sync # install dependencies
103
+ uv run pytest test # run tests
104
+ uv run sphinx-build docs/ docs/_build # build documentation
105
+ ```
106
+
107
+ ## Issue
108
+
109
+ If there are some bugs, please make issue to tell me!
110
+
111
+ [![GitHub issues](https://img.shields.io/github/issues/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/issues)
112
+
113
+ ## License
114
+
115
+ MIT License
116
+
117
+ [![GitHub](https://img.shields.io/github/license/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper?tab=MIT-1-ov-file#MIT-1-ov-file)
@@ -0,0 +1,99 @@
1
+ # plotly_extend_wrapper
2
+
3
+ [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Laplusdestiny/plotly_extend_wrapper/main?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/commits/main/)
4
+ [![Codecov](https://img.shields.io/codecov/c/gh/Laplusdestiny/plotly_extend_wrapper?style=flat&logo=codecov)](https://app.codecov.io/gh/Laplusdestiny/plotly_extend_wrapper)
5
+ [![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/releases)
6
+ [![PyPI - Version](https://img.shields.io/pypi/v/plotly_extend_wrapper?logo=pypi)](https://pypi.org/project/plotly-extend-wrapper/)
7
+
8
+ Extended Python library for Plotly
9
+
10
+ - **Simple Interface**: Create complex visualizations with just a few lines of code
11
+ - **pandas / polars Support**: Accepts `pandas.DataFrame`, `polars.DataFrame` and `polars.LazyFrame`
12
+ - **Automated Preprocessing**: Value counting, rounding and pivoting are handled for you
13
+ - **Multiple Plot Types**: Pie, sunburst, bubble, line (with secondary y-axis), and 3D surface charts
14
+ - **Customization**: Update titles, legend, size and markers through a unified interface
15
+
16
+ For detailed documentation and examples, visit our [Documentation](https://laplusdestiny.github.io/plotly_extend_wrapper/)
17
+
18
+ ## Install
19
+
20
+ ``` bash
21
+ pip install plotly-extend-wrapper
22
+
23
+ # with polars support
24
+ pip install "plotly-extend-wrapper[polars]"
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ``` python
30
+ import pandas as pd
31
+ from plotly_extend_wrapper import Plot_pie, Plot_line, Update_plotly_object
32
+
33
+ df = pd.DataFrame({"category": ["A", "B", "A", "C", "B"]})
34
+ fig = Plot_pie(df, "category") # value counts are computed automatically
35
+
36
+ df = pd.DataFrame({
37
+ "date": pd.date_range("2024-01-01", periods=100, freq="D"),
38
+ "sales": range(100),
39
+ "temperature": [i % 30 for i in range(100)],
40
+ })
41
+ fig = Plot_line(
42
+ df,
43
+ x="date",
44
+ y=["sales"],
45
+ secondary_y=["temperature"],
46
+ ytitle="Sales",
47
+ secondary_ytitle="Temperature",
48
+ vline=["2024-02-01"],
49
+ )
50
+
51
+ updater = Update_plotly_object(fig)
52
+ updater.update(height=500, width=900, legend_position="h")
53
+ updater.write_image("output/line.png")
54
+ ```
55
+
56
+ ## Supported Functions
57
+
58
+ | Name | Description |
59
+ | --- | --- |
60
+ | `Plot_pie` | Pie chart from the value counts of a column |
61
+ | `Plot_sunburst` | Hierarchical sunburst chart from the value counts of multiple columns |
62
+ | `Plot_bubble_chart` | Bubble chart whose size is the frequency of (x, y) pairs |
63
+ | `Plot_bubble_chart_with_line` | Overlay linear lines (`y = a * x + b`) on a bubble chart |
64
+ | `Plot_line` | Line chart with secondary y-axis, highlighted periods and vertical lines |
65
+ | `Plot_surface` | 3D surface plot with optional cubic interpolation |
66
+ | `Update_plotly_object` | Update layout of an existing figure and export it as an image |
67
+ | `check_directory` | Create parent directories for an output path |
68
+
69
+ ## Requirement
70
+
71
+ - Python >= 3.9
72
+ - plotly >= 6.1.0
73
+ - kaleido >= 0.2.1
74
+ - pandas >= 2.0.0
75
+ - pyarrow >= 10.0.0
76
+ - numpy >= 1.24.0
77
+ - scipy >= 1.8.0
78
+ - nbformat >= 4.2.0
79
+ - polars >= 0.20.0 (optional)
80
+
81
+ ## Development
82
+
83
+ ``` bash
84
+ uv sync # install dependencies
85
+ uv run pytest test # run tests
86
+ uv run sphinx-build docs/ docs/_build # build documentation
87
+ ```
88
+
89
+ ## Issue
90
+
91
+ If there are some bugs, please make issue to tell me!
92
+
93
+ [![GitHub issues](https://img.shields.io/github/issues/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/issues)
94
+
95
+ ## License
96
+
97
+ MIT License
98
+
99
+ [![GitHub](https://img.shields.io/github/license/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper?tab=MIT-1-ov-file#MIT-1-ov-file)
@@ -0,0 +1,10 @@
1
+ from plotly_extend_wrapper.wrapper import *
2
+ from plotly_extend_wrapper.updater import *
3
+ from plotly_extend_wrapper.common import *
4
+
5
+ from importlib.metadata import PackageNotFoundError, version as _version
6
+
7
+ try:
8
+ __version__ = _version("plotly-extend-wrapper")
9
+ except PackageNotFoundError:
10
+ __version__ = "unknown"
@@ -0,0 +1,22 @@
1
+ from pathlib import Path
2
+ from plotly.io import get_chrome
3
+
4
+
5
+ def check_directory(file_path):
6
+ """
7
+ Ensures that the directory for the given file path exists, creating it if necessary.
8
+
9
+ Args:
10
+ file_path (str or Path): The file path for which to check the directory.
11
+
12
+ Returns:
13
+ Path: The resolved absolute path of the given file path.
14
+ """
15
+ file_path = Path(file_path)
16
+ if not file_path.suffix:
17
+ dir_p = file_path
18
+ else:
19
+ dir_p = file_path.parent
20
+ if not dir_p.is_dir():
21
+ dir_p.mkdir(parents=True, exist_ok=True)
22
+ return file_path.resolve()
@@ -6,15 +6,52 @@ from plotly import graph_objects as go
6
6
  from scipy.interpolate import griddata
7
7
  import numpy as np
8
8
  from copy import deepcopy
9
+ from typing import Union
9
10
 
11
+ # Optional polars support
12
+ try:
13
+ import polars as pl
14
+ POLARS_AVAILABLE = True
15
+ except ImportError:
16
+ POLARS_AVAILABLE = False
17
+ pl = None
10
18
 
11
- def Plot_pie(data: pd.DataFrame, target: str, **kwargs):
19
+
20
+ def _normalize_dataframe(data) -> pd.DataFrame:
21
+ """
22
+ Convert various DataFrame formats to pandas.DataFrame.
23
+
24
+ Supports pandas.DataFrame, polars.DataFrame, and polars.LazyFrame.
25
+
26
+ Parameters
27
+ ----------
28
+ data : pd.DataFrame, pl.DataFrame, or pl.LazyFrame
29
+ Input data frame
30
+
31
+ Returns
32
+ -------
33
+ pd.DataFrame
34
+ Normalized pandas DataFrame
35
+ """
36
+ if POLARS_AVAILABLE and pl is not None:
37
+ if isinstance(data, pl.LazyFrame):
38
+ return data.collect().to_pandas()
39
+ elif isinstance(data, pl.DataFrame):
40
+ return data.to_pandas()
41
+
42
+ if isinstance(data, pd.DataFrame):
43
+ return data
44
+
45
+ raise TypeError(f"Unsupported data type: {type(data)}. Expected pandas.DataFrame, polars.DataFrame, or polars.LazyFrame.")
46
+
47
+
48
+ def Plot_pie(data: Union[pd.DataFrame, "pl.DataFrame", "pl.LazyFrame"], target: str, **kwargs):
12
49
  """Make pie plot
13
50
 
14
51
  Parameters
15
52
  ----------
16
- data : pd.DataFrame
17
- pandas.DataFrame included data to make pie chart
53
+ data : pd.DataFrame, pl.DataFrame, or pl.LazyFrame
54
+ DataFrame included data to make pie chart
18
55
  target : str
19
56
  String which column you would like to use for pie chart
20
57
 
@@ -23,17 +60,18 @@ def Plot_pie(data: pd.DataFrame, target: str, **kwargs):
23
60
  plotly.graph_objects
24
61
  Object of pie chart
25
62
  """
63
+ data = _normalize_dataframe(data)
26
64
  vc = data[target].value_counts().reset_index(name="count")
27
65
  return px.pie(vc, names=target, values="count", **kwargs)
28
66
 
29
67
 
30
- def Plot_sunburst(data: pd.DataFrame, groups: list, **kwargs):
68
+ def Plot_sunburst(data: Union[pd.DataFrame, "pl.DataFrame", "pl.LazyFrame"], groups: list, **kwargs):
31
69
  """Make sunburst plot
32
70
 
33
71
  Parameters
34
72
  ----------
35
- data : pd.DataFrame
36
- pandas.DataFrame included data to make sunburst chart
73
+ data : pd.DataFrame, pl.DataFrame, or pl.LazyFrame
74
+ DataFrame included data to make sunburst chart
37
75
  groups : list
38
76
  Strings list of group
39
77
  Changed when you replace the order
@@ -43,6 +81,7 @@ def Plot_sunburst(data: pd.DataFrame, groups: list, **kwargs):
43
81
  plotly.graph_objects
44
82
  Object of sunburst chart
45
83
  """
84
+ data = _normalize_dataframe(data)
46
85
  vc = data.value_counts(subset=groups).reset_index(name="count")
47
86
  return px.sunburst(vc, path=groups, values="count", **kwargs)
48
87
 
@@ -69,8 +108,8 @@ class Plot_bubble_chart:
69
108
 
70
109
  Parameters
71
110
  ----------
72
- df : pandas.DataFrame
73
- pandas.DataFrame included data to make plot
111
+ df : pandas.DataFrame, pl.DataFrame, or pl.LazyFrame
112
+ DataFrame included data to make plot
74
113
  x : str
75
114
  X-axis column's name
76
115
  y : str
@@ -92,6 +131,7 @@ class Plot_bubble_chart:
92
131
  offset : int, optional
93
132
  Offset value for bubble size, by default 0
94
133
  """
134
+ df = _normalize_dataframe(df)
95
135
  self.df = df.copy()
96
136
  self.x = x
97
137
  self.y = y
@@ -188,7 +228,7 @@ class Plot_bubble_chart:
188
228
 
189
229
 
190
230
  def Plot_line(
191
- df: pd.DataFrame,
231
+ df: Union[pd.DataFrame, "pl.DataFrame", "pl.LazyFrame"],
192
232
  x: str,
193
233
  y: list,
194
234
  secondary_y: list,
@@ -210,7 +250,7 @@ def Plot_line(
210
250
 
211
251
  Parameters
212
252
  ----------
213
- df : pd.DataFrame
253
+ df : pd.DataFrame, pl.DataFrame, or pl.LazyFrame
214
254
  Original dataframe
215
255
  x : str
216
256
  X-axis column name
@@ -250,10 +290,12 @@ def Plot_line(
250
290
  """
251
291
  import random
252
292
 
253
- random.seed(42)
293
+ rng = random.Random(42)
294
+
295
+ df = _normalize_dataframe(df)
254
296
 
255
297
  def pick_color():
256
- return ["#" + "".join([random.choice("0123456789ABCDEF") for j in range(6)])][0]
298
+ return ["#" + "".join([rng.choice("0123456789ABCDEF") for j in range(6)])][0]
257
299
 
258
300
  if isinstance(secondary_y, str):
259
301
  secondary_y = [secondary_y]
@@ -402,7 +444,7 @@ def Plot_bubble_chart_with_line(
402
444
 
403
445
 
404
446
  def Plot_surface(
405
- df: pd.DataFrame,
447
+ df: Union[pd.DataFrame, "pl.DataFrame", "pl.LazyFrame"],
406
448
  x: str,
407
449
  y: str,
408
450
  z: str,
@@ -414,6 +456,26 @@ def Plot_surface(
414
456
  width=None,
415
457
  **kwargs,
416
458
  ):
459
+ """
460
+ Generates a 3D surface plot using Plotly.
461
+
462
+ Parameters:
463
+ df (pd.DataFrame, pl.DataFrame, or pl.LazyFrame): The input data frame containing the data to plot.
464
+ x (str): The column name for the x-axis.
465
+ y (str): The column name for the y-axis.
466
+ z (str): The column name for the z-axis.
467
+ fill_value (int, optional): The value to fill missing data in the pivot table. Default is 0.
468
+ smoothing (bool, optional): Whether to apply smoothing to the data. Default is False.
469
+ smooth_point_num (int, optional): The number of points to use for smoothing. Default is 100.
470
+ title (str, optional): The title of the plot. Default is None.
471
+ height (int, optional): The height of the plot. Default is None.
472
+ width (int, optional): The width of the plot. Default is None.
473
+ **kwargs: Additional keyword arguments passed to plotly.graph_objects.Surface.
474
+
475
+ Returns:
476
+ plotly.graph_objs._figure.Figure: The generated 3D surface plot.
477
+ """
478
+
417
479
  def smooth_df(x: np.ndarray, y: np.ndarray, z: np.ndarray, num: int):
418
480
  xi = np.linspace(x.min(), x.max(), num)
419
481
  yi = np.linspace(y.min(), y.max(), num)
@@ -423,6 +485,8 @@ def Plot_surface(
423
485
  zi = np.nan_to_num(zi)
424
486
  return xi, yi, zi
425
487
 
488
+ df = _normalize_dataframe(df)
489
+
426
490
  if smoothing:
427
491
  X = df[x].values
428
492
  Y = df[y].values
@@ -430,17 +494,18 @@ def Plot_surface(
430
494
  X, Y, Z = smooth_df(X, Y, Z, smooth_point_num)
431
495
  else:
432
496
  pivot_df = pd.pivot_table(
433
- df, index=x, columns=y, values=z, fill_value=fill_value)
497
+ df, index=x, columns=y, values=z, fill_value=fill_value
498
+ )
434
499
 
435
500
  X = pivot_df.columns.values
436
501
  Y = pivot_df.index.values
437
502
  Z = pivot_df.values
438
503
 
439
- data = [go.Surface(x=X, y=Y, z=Z)]
504
+ data = [go.Surface(x=X, y=Y, z=Z, **kwargs)]
440
505
  layout = go.Layout(
441
506
  title=title,
442
507
  scene=dict(
443
- xaxis=dict(title=y), # need to be replaced
508
+ xaxis=dict(title=y), # need to be replaced
444
509
  yaxis=dict(title=x),
445
510
  zaxis=dict(title=z),
446
511
  ),
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: plotly-extend-wrapper
3
+ Version: 1.5.0
4
+ Author-email: Laplusdestiny <prayonshootingstars@gmail.com>
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: plotly>=6.1.0
9
+ Requires-Dist: kaleido>=0.2.1
10
+ Requires-Dist: pyarrow>=10.0.0
11
+ Requires-Dist: pandas>=2.0.0
12
+ Requires-Dist: scipy>=1.8.0
13
+ Requires-Dist: numpy>=1.24.0
14
+ Requires-Dist: nbformat>=4.2.0
15
+ Provides-Extra: polars
16
+ Requires-Dist: polars>=0.20.0; extra == "polars"
17
+ Dynamic: license-file
18
+
19
+ # plotly_extend_wrapper
20
+
21
+ [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Laplusdestiny/plotly_extend_wrapper/main?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/commits/main/)
22
+ [![Codecov](https://img.shields.io/codecov/c/gh/Laplusdestiny/plotly_extend_wrapper?style=flat&logo=codecov)](https://app.codecov.io/gh/Laplusdestiny/plotly_extend_wrapper)
23
+ [![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/releases)
24
+ [![PyPI - Version](https://img.shields.io/pypi/v/plotly_extend_wrapper?logo=pypi)](https://pypi.org/project/plotly-extend-wrapper/)
25
+
26
+ Extended Python library for Plotly
27
+
28
+ - **Simple Interface**: Create complex visualizations with just a few lines of code
29
+ - **pandas / polars Support**: Accepts `pandas.DataFrame`, `polars.DataFrame` and `polars.LazyFrame`
30
+ - **Automated Preprocessing**: Value counting, rounding and pivoting are handled for you
31
+ - **Multiple Plot Types**: Pie, sunburst, bubble, line (with secondary y-axis), and 3D surface charts
32
+ - **Customization**: Update titles, legend, size and markers through a unified interface
33
+
34
+ For detailed documentation and examples, visit our [Documentation](https://laplusdestiny.github.io/plotly_extend_wrapper/)
35
+
36
+ ## Install
37
+
38
+ ``` bash
39
+ pip install plotly-extend-wrapper
40
+
41
+ # with polars support
42
+ pip install "plotly-extend-wrapper[polars]"
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ``` python
48
+ import pandas as pd
49
+ from plotly_extend_wrapper import Plot_pie, Plot_line, Update_plotly_object
50
+
51
+ df = pd.DataFrame({"category": ["A", "B", "A", "C", "B"]})
52
+ fig = Plot_pie(df, "category") # value counts are computed automatically
53
+
54
+ df = pd.DataFrame({
55
+ "date": pd.date_range("2024-01-01", periods=100, freq="D"),
56
+ "sales": range(100),
57
+ "temperature": [i % 30 for i in range(100)],
58
+ })
59
+ fig = Plot_line(
60
+ df,
61
+ x="date",
62
+ y=["sales"],
63
+ secondary_y=["temperature"],
64
+ ytitle="Sales",
65
+ secondary_ytitle="Temperature",
66
+ vline=["2024-02-01"],
67
+ )
68
+
69
+ updater = Update_plotly_object(fig)
70
+ updater.update(height=500, width=900, legend_position="h")
71
+ updater.write_image("output/line.png")
72
+ ```
73
+
74
+ ## Supported Functions
75
+
76
+ | Name | Description |
77
+ | --- | --- |
78
+ | `Plot_pie` | Pie chart from the value counts of a column |
79
+ | `Plot_sunburst` | Hierarchical sunburst chart from the value counts of multiple columns |
80
+ | `Plot_bubble_chart` | Bubble chart whose size is the frequency of (x, y) pairs |
81
+ | `Plot_bubble_chart_with_line` | Overlay linear lines (`y = a * x + b`) on a bubble chart |
82
+ | `Plot_line` | Line chart with secondary y-axis, highlighted periods and vertical lines |
83
+ | `Plot_surface` | 3D surface plot with optional cubic interpolation |
84
+ | `Update_plotly_object` | Update layout of an existing figure and export it as an image |
85
+ | `check_directory` | Create parent directories for an output path |
86
+
87
+ ## Requirement
88
+
89
+ - Python >= 3.9
90
+ - plotly >= 6.1.0
91
+ - kaleido >= 0.2.1
92
+ - pandas >= 2.0.0
93
+ - pyarrow >= 10.0.0
94
+ - numpy >= 1.24.0
95
+ - scipy >= 1.8.0
96
+ - nbformat >= 4.2.0
97
+ - polars >= 0.20.0 (optional)
98
+
99
+ ## Development
100
+
101
+ ``` bash
102
+ uv sync # install dependencies
103
+ uv run pytest test # run tests
104
+ uv run sphinx-build docs/ docs/_build # build documentation
105
+ ```
106
+
107
+ ## Issue
108
+
109
+ If there are some bugs, please make issue to tell me!
110
+
111
+ [![GitHub issues](https://img.shields.io/github/issues/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper/issues)
112
+
113
+ ## License
114
+
115
+ MIT License
116
+
117
+ [![GitHub](https://img.shields.io/github/license/Laplusdestiny/plotly_extend_wrapper?logo=github)](https://github.com/Laplusdestiny/plotly_extend_wrapper?tab=MIT-1-ov-file#MIT-1-ov-file)
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ plotly_extend_wrapper/__init__.py
5
+ plotly_extend_wrapper/common.py
6
+ plotly_extend_wrapper/updater.py
7
+ plotly_extend_wrapper/wrapper.py
8
+ plotly_extend_wrapper.egg-info/PKG-INFO
9
+ plotly_extend_wrapper.egg-info/SOURCES.txt
10
+ plotly_extend_wrapper.egg-info/dependency_links.txt
11
+ plotly_extend_wrapper.egg-info/requires.txt
12
+ plotly_extend_wrapper.egg-info/top_level.txt
13
+ test/test_common.py
14
+ test/test_updater.py
15
+ test/test_version.py
16
+ test/test_wrapper.py
17
+ test/test_wrapper_polars.py
@@ -0,0 +1,10 @@
1
+ plotly>=6.1.0
2
+ kaleido>=0.2.1
3
+ pyarrow>=10.0.0
4
+ pandas>=2.0.0
5
+ scipy>=1.8.0
6
+ numpy>=1.24.0
7
+ nbformat>=4.2.0
8
+
9
+ [polars]
10
+ polars>=0.20.0
@@ -0,0 +1 @@
1
+ plotly_extend_wrapper
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "plotly-extend-wrapper"
3
+ version = "1.5.0"
4
+ authors = [{ name = "Laplusdestiny", email = "prayonshootingstars@gmail.com" }]
5
+ dependencies = [
6
+ "plotly>=6.1.0",
7
+ "kaleido>=0.2.1",
8
+ "pyarrow>=10.0.0",
9
+ "pandas>=2.0.0",
10
+ "scipy>=1.8.0",
11
+ "numpy>=1.24.0",
12
+ "nbformat>=4.2.0",
13
+ ]
14
+ readme = "README.md"
15
+ requires-python = ">= 3.9"
16
+
17
+ [project.optional-dependencies]
18
+ polars = ["polars>=0.20.0"]
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ "build>=1.4.0",
23
+ "furo>=2025.12.19",
24
+ "ipykernel>=6.31.0",
25
+ "myst-parser>=3.0.1",
26
+ "polars>=0.20.0",
27
+ "pytest>=8.4.2",
28
+ "pytest-cov>=7.0.0",
29
+ "scikit-learn>=1.6.1",
30
+ "sphinx>=7.4.7",
31
+ "twine>=6.2.0",
32
+ "wheel>=0.46.3",
33
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+