ggplot2-python 4.0.2.9000__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.
Files changed (54) hide show
  1. ggplot2_py/__init__.py +852 -0
  2. ggplot2_py/_compat.py +475 -0
  3. ggplot2_py/_plugins.py +129 -0
  4. ggplot2_py/_utils.py +544 -0
  5. ggplot2_py/aes.py +586 -0
  6. ggplot2_py/annotation.py +540 -0
  7. ggplot2_py/coord.py +2108 -0
  8. ggplot2_py/coords/__init__.py +49 -0
  9. ggplot2_py/datasets.py +265 -0
  10. ggplot2_py/draw_key.py +454 -0
  11. ggplot2_py/facet.py +1456 -0
  12. ggplot2_py/fortify.py +95 -0
  13. ggplot2_py/geom.py +4516 -0
  14. ggplot2_py/geoms/__init__.py +12 -0
  15. ggplot2_py/ggproto.py +279 -0
  16. ggplot2_py/guide.py +2925 -0
  17. ggplot2_py/guide_axis.py +615 -0
  18. ggplot2_py/guide_colourbar.py +657 -0
  19. ggplot2_py/guide_legend.py +1061 -0
  20. ggplot2_py/guides/__init__.py +8 -0
  21. ggplot2_py/labeller.py +296 -0
  22. ggplot2_py/labels.py +309 -0
  23. ggplot2_py/layer.py +954 -0
  24. ggplot2_py/layout.py +754 -0
  25. ggplot2_py/limits.py +314 -0
  26. ggplot2_py/plot.py +1401 -0
  27. ggplot2_py/plot_render.py +866 -0
  28. ggplot2_py/position.py +1269 -0
  29. ggplot2_py/protocols.py +171 -0
  30. ggplot2_py/py.typed +0 -0
  31. ggplot2_py/qplot.py +233 -0
  32. ggplot2_py/resources/diamonds.csv +53941 -0
  33. ggplot2_py/resources/economics.csv +575 -0
  34. ggplot2_py/resources/economics_long.csv +2871 -0
  35. ggplot2_py/resources/faithfuld.csv +5626 -0
  36. ggplot2_py/resources/luv_colours.csv +658 -0
  37. ggplot2_py/resources/midwest.csv +438 -0
  38. ggplot2_py/resources/mpg.csv +235 -0
  39. ggplot2_py/resources/msleep.csv +84 -0
  40. ggplot2_py/resources/presidential.csv +13 -0
  41. ggplot2_py/resources/seals.csv +1156 -0
  42. ggplot2_py/resources/txhousing.csv +8603 -0
  43. ggplot2_py/save.py +316 -0
  44. ggplot2_py/scale.py +2727 -0
  45. ggplot2_py/scales/__init__.py +4252 -0
  46. ggplot2_py/stat.py +6071 -0
  47. ggplot2_py/stats/__init__.py +9 -0
  48. ggplot2_py/theme.py +490 -0
  49. ggplot2_py/theme_defaults.py +1350 -0
  50. ggplot2_py/theme_elements.py +2052 -0
  51. ggplot2_python-4.0.2.9000.dist-info/METADATA +179 -0
  52. ggplot2_python-4.0.2.9000.dist-info/RECORD +54 -0
  53. ggplot2_python-4.0.2.9000.dist-info/WHEEL +4 -0
  54. ggplot2_python-4.0.2.9000.dist-info/licenses/LICENSE +3 -0
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: ggplot2-python
3
+ Version: 4.0.2.9000
4
+ Summary: Python port of the R ggplot2 package (tracks R ggplot2 4.0.2.9000)
5
+ Project-URL: Homepage, https://github.com/Bio-Babel/ggplot2-python
6
+ Project-URL: Repository, https://github.com/Bio-Babel/ggplot2-python
7
+ Project-URL: Issues, https://github.com/Bio-Babel/ggplot2-python/issues
8
+ Project-URL: Documentation, https://github.com/Bio-Babel/ggplot2-python#readme
9
+ Author-email: Jeffery Liu <jeffliu.lucky@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: R-port,data-visualization,ggplot2,grammar-of-graphics,plotting,statistical-graphics,visualization
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Scientific/Engineering :: Visualization
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: contourpy>=1.0
28
+ Requires-Dist: geopandas>=0.12
29
+ Requires-Dist: gtable-python>=0.3.6
30
+ Requires-Dist: matplotlib>=3.6
31
+ Requires-Dist: numpy>=1.24
32
+ Requires-Dist: pandas>=1.5
33
+ Requires-Dist: pillow>=9.0
34
+ Requires-Dist: rgrid-python>=4.5.3
35
+ Requires-Dist: scales-python>=1.4.0
36
+ Requires-Dist: scipy>=1.10
37
+ Requires-Dist: statsmodels>=0.13
38
+ Provides-Extra: dev
39
+ Requires-Dist: build; extra == 'dev'
40
+ Requires-Dist: pytest; extra == 'dev'
41
+ Requires-Dist: pytest-cov; extra == 'dev'
42
+ Requires-Dist: ruff; extra == 'dev'
43
+ Requires-Dist: twine; extra == 'dev'
44
+ Provides-Extra: docs
45
+ Requires-Dist: mkdocs; extra == 'docs'
46
+ Requires-Dist: mkdocs-jupyter; extra == 'docs'
47
+ Requires-Dist: mkdocs-material; extra == 'docs'
48
+ Requires-Dist: mkdocstrings[python]; extra == 'docs'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # ggplot2_py <a href="https://github.com/R2pyBioinformatics/ggplot2_py"><img src="assets/ggplot2_py_logo.png" align="right" height="138" alt="ggplot2_py logo" /></a>
52
+
53
+ AI-assisted Python port of the R **ggplot2** package — Create Elegant Data Visualisations Using the Grammar of Graphics.
54
+
55
+ ## Overview
56
+
57
+ ggplot2_py implements the grammar of graphics in Python, faithfully porting R's ggplot2 using pandas DataFrames as the data container and a Cairo-based rendering backend. It supports 47 geoms, 32 stats, faceting, coordinate systems, themes, guides, and 130+ scales.
58
+
59
+ Beyond a direct port, ggplot2_py adds **Python-exclusive features** that extend the Grammar of Graphics with Python-native idioms while preserving full orthogonality of GOG components.
60
+
61
+ ## Python-Exclusive Features
62
+
63
+ These capabilities have no R equivalent and leverage Python-specific language features:
64
+
65
+ | Feature | Python mechanism | What it enables |
66
+ |---------|-----------------|-----------------|
67
+ | **Callable `aes()` expressions** | First-class functions / lambdas | `aes(y=lambda d: np.log(d["mpg"]))` — inline data transforms without pre-computing columns |
68
+ | **`after_stat()` / `after_scale()` callables** | Same | `after_stat(lambda d: d["count"] / d["count"].sum())` — arbitrary expressions at each pipeline stage |
69
+ | **`singledispatch` extensibility** | `functools.singledispatch` | `@update_ggplot.register(MyClass)` — any Python class can be added to a plot with `+` |
70
+ | **Build hooks** | Dict-keyed callback lists | `plot.add_build_hook("after", BuildStage.COMPUTE_STAT, fn)` — intercept data at any of 16 named pipeline stages |
71
+ | **Auto-registration** | `__init_subclass__` | `class GeomStar(Geom): ...` auto-registers; no manual wiring needed |
72
+ | **Protocol contracts** | `typing.Protocol` | `isinstance(my_geom, GeomProtocol)` — structural type checking for extensions |
73
+ | **Scoped defaults** | `contextvars.ContextVar` | `with ggplot_defaults(theme=theme_minimal()): ...` — thread-safe scoped defaults |
74
+
75
+ ## Installation
76
+
77
+ ```bash
78
+ # From PyPI
79
+ pip install ggplot2-python
80
+ ```
81
+
82
+ For a local development:
83
+
84
+ ```bash
85
+ git clone https://github.com/Bio-Babel/ggplot2-python.git
86
+ cd ggplot2_py
87
+ pip install -e ".[dev]"
88
+ ```
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ from ggplot2_py import *
94
+ from ggplot2_py.datasets import mpg
95
+
96
+ (ggplot(mpg, aes(x="displ", y="hwy", colour="class"))
97
+ + geom_point()
98
+ + geom_smooth(method="lm")
99
+ + facet_wrap("drv")
100
+ + theme_minimal()
101
+ + labs(title="Engine Displacement vs Highway MPG"))
102
+ ```
103
+
104
+ ### Callable expressions in aes (Python-exclusive)
105
+
106
+ ```python
107
+ import numpy as np
108
+ from ggplot2_py import ggplot, aes, geom_point, geom_histogram, after_stat
109
+
110
+ # Inline data transform — no need to pre-compute a column
111
+ ggplot(mpg, aes(x=lambda d: np.log(d["displ"]), y="hwy")) + geom_point()
112
+
113
+ # Normalised histogram — callable in after_stat
114
+ (ggplot(mpg, aes(x="hwy"))
115
+ + geom_histogram(aes(y=after_stat(lambda d: d["count"] / d["count"].sum())), bins=15))
116
+ ```
117
+
118
+ ### Extending with custom types (Python-exclusive)
119
+
120
+ ```python
121
+ from ggplot2_py import update_ggplot
122
+
123
+ class Watermark:
124
+ def __init__(self, text): self.text = text
125
+
126
+ @update_ggplot.register(Watermark)
127
+ def _add_watermark(obj, plot, object_name=""):
128
+ plot.labels["caption"] = f"[{obj.text}]"
129
+ return plot
130
+
131
+ # Now use with +
132
+ ggplot(mpg, aes("displ", "hwy")) + geom_point() + Watermark("DRAFT")
133
+ ```
134
+
135
+ ### Scoped defaults (Python-exclusive)
136
+
137
+ ```python
138
+ from ggplot2_py import ggplot_defaults
139
+
140
+ with ggplot_defaults(theme=theme_minimal()):
141
+ p1 = ggplot(df, aes("x", "y")) + geom_point() # theme_minimal applied
142
+ p2 = ggplot(df, aes("x", "y")) + geom_bar() # theme_minimal applied
143
+ # Outside: no defaults
144
+ ```
145
+
146
+ ## Tutorials
147
+
148
+ ### User Tutorials
149
+ - [Getting Started](tutorials/ggplot2.ipynb) — core concepts: data, aes, geoms, stats, scales, facets, coords, themes
150
+ - [Geom Gallery](tutorials/geoms_gallery.ipynb) — boxplot, violin, density, tile, hex and combinations
151
+ - [Labels & Facets](tutorials/labels_and_facets.ipynb) — axis titles, plot title/subtitle/caption, facet strip labels
152
+ - [Aesthetic Specs](tutorials/aesthetic_specs.ipynb) — colour, fill, alpha, linetype, shape, size, colour scales
153
+ - [Extending ggplot2](tutorials/extending_ggplot2.ipynb) — custom stats, geoms, themes via ggproto
154
+
155
+ ### Python-Exclusive Feature Tutorials
156
+ - [Callable aes Expressions](tutorials/aes_expressions.ipynb) — lambdas in `aes()`, `after_stat()`, `after_scale()`, `stage()`
157
+ - [Extensible Pipeline](tutorials/pipeline_dispatch.ipynb) — `singledispatch` registration, custom types with `+`
158
+ - [Build Hooks](tutorials/build_hooks.ipynb) — intercepting the 16-stage build pipeline
159
+
160
+ ### Developer Guide
161
+ - [Developer Guide: Extending ggplot2_py](tutorials/developer_guide.ipynb) — comprehensive guide covering ggproto system, custom Stat/Geom creation, Protocol contracts, singledispatch, hooks, auto-registration, context manager, and packaging
162
+
163
+ ## Extension Architecture
164
+
165
+ ggplot2_py is designed as an **extensible platform**. The following table summarises all extension points:
166
+
167
+ | Extension point | Mechanism | How to use |
168
+ |----------------|-----------|-----------|
169
+ | Custom Stat | Subclass `Stat` | Override `compute_group()` — auto-registered via `__init_subclass__` |
170
+ | Custom Geom | Subclass `Geom` | Override `draw_panel()` — auto-registered |
171
+ | Custom Scale | Subclass `ScaleContinuous` / `ScaleDiscrete` | Implement `train()`, `map()`, `get_breaks()` |
172
+ | Custom Coord | Subclass `Coord` | Override `transform()`, `setup_panel_params()` |
173
+ | Custom Facet | Subclass `Facet` | Override `compute_layout()`, `map_data()` |
174
+ | Custom Position | Subclass `Position` | Override `compute_layer()` — auto-registered |
175
+ | Custom `+` types | `@update_ggplot.register(MyClass)` | Register any Python class for the `+` operator |
176
+ | Custom plot types | `@ggplot_build.register(MyPlot)` | Override the entire build pipeline |
177
+ | Build hooks | `plot.add_build_hook(timing, stage, fn)` | Intercept data at any pipeline stage |
178
+ | Protocol validation | `isinstance(obj, GeomProtocol)` | Verify structural conformance |
179
+ | Scoped defaults | `with ggplot_defaults(theme=...):` | Thread-safe scoped defaults |
@@ -0,0 +1,54 @@
1
+ ggplot2_py/__init__.py,sha256=_hNuH6YGAjWUXOM-4J0ledrAIG6EI6Qj9JmIVwf6pTM,24411
2
+ ggplot2_py/_compat.py,sha256=sLzzhq0ii2eSx1xMRaHemNnNqUd6FfT3wRierE1EXCg,10670
3
+ ggplot2_py/_plugins.py,sha256=TLsSEfN5L5VyWtsHaV_fms3TjQezUDUWWEj8ctVxK88,4323
4
+ ggplot2_py/_utils.py,sha256=Qyh2ORUgLlT_rgJ9IaJpzej6G7BIK13nzBR1hF5Zjtw,13612
5
+ ggplot2_py/aes.py,sha256=pGlvRo893GBFE_uxgh6pHrFb0QR2fu57WJ-XfEHzvc0,17031
6
+ ggplot2_py/annotation.py,sha256=g-m5954fFq0FcKnjBBrZTP9m__Kk04df85voCXv_mwE,14863
7
+ ggplot2_py/coord.py,sha256=IxkLU2tZBkWpuo2UVsc54LT7lKuhKm9T9VWO6kXjFmg,65687
8
+ ggplot2_py/datasets.py,sha256=wYFX7mlhe6KiUwggjt6f72-T3ikelwzfdIlttbIu_os,6708
9
+ ggplot2_py/draw_key.py,sha256=apH36BxxjiMxuKjJzpo371I8uk97hy9SDZ1eFBbiC_Y,12472
10
+ ggplot2_py/facet.py,sha256=8mtbAic1dRgoZZtgMrheWa3M_Thy_0KiLw4LUiIs-Cw,46608
11
+ ggplot2_py/fortify.py,sha256=hjIp2EnBnkeVhSUNmXlz4RYVNmuffFHTrHqUdAvFONU,2798
12
+ ggplot2_py/geom.py,sha256=fHC4IIBqm5VZ732zBDGnj3h8VMBblp4RFQZMHSMACZ4,151174
13
+ ggplot2_py/ggproto.py,sha256=cWcEBUHQkSrAitCPv1M7MdLJSXRzskOk-VETKXOeMdA,8510
14
+ ggplot2_py/guide.py,sha256=VIXCNAIcq5QmKfs-y_vC-RSC_QY1YSC58WD4l8t_JDQ,79876
15
+ ggplot2_py/guide_axis.py,sha256=-wfDumlLMriqHp-9k66jKr3ytrin61xe3i8h-DVqSuM,22338
16
+ ggplot2_py/guide_colourbar.py,sha256=cm7kd6Uu8NsaUBWc8jsdkfQcuU_GEGkjCHMqgZyUpzA,20420
17
+ ggplot2_py/guide_legend.py,sha256=duheTtTiTwU6WzjyInrNuJEh8uLKMJ9Y1Ju6UJjhGBc,37298
18
+ ggplot2_py/labeller.py,sha256=vMPePSFy6rRHoKqZOmrdAWh-loQixJggBBn0Zq6Wy2U,7969
19
+ ggplot2_py/labels.py,sha256=8JkSdSdpICcItyBv5RPh4PmzF4TzOnF5_umTHhul5Ro,8306
20
+ ggplot2_py/layer.py,sha256=de6GyIir0L7GLgGQ3e4w3VTKOEwW5h34zmZvlmCg5ZA,29346
21
+ ggplot2_py/layout.py,sha256=QkaGP3anrQYS8vIFMlsz3jKmblHUTYGSevCXIMGlDns,25341
22
+ ggplot2_py/limits.py,sha256=e1WezeXnqPUKn6aaNgyDkLkF1JbxustqfQorKrmjPHI,8219
23
+ ggplot2_py/plot.py,sha256=tMdrEosF9la9rK_QxcRGjFMWvcO7xBg8eG2_kMZy_fM,41102
24
+ ggplot2_py/plot_render.py,sha256=cwdLBFFQn0flsx2L7eg6kPFQ97OMIFprIxqIo1APkIk,29149
25
+ ggplot2_py/position.py,sha256=weKCXpnDtif0NZ9cZqOEs4J96GJhMxUZiBFhZgt0IFM,34339
26
+ ggplot2_py/protocols.py,sha256=7d34T7v7NLg3N1bSEPmmPFrV-5BZvnzBsbpiqnDatZA,5353
27
+ ggplot2_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
+ ggplot2_py/qplot.py,sha256=gZ6BWdU2bZwN1zwJCi9unOeWGDVEmV_FQPqb2X6-2TU,6551
29
+ ggplot2_py/save.py,sha256=CVj-oZzdzUm14JQv6nQsaxgJcurDr1M-4Rjs2U0xoqQ,9055
30
+ ggplot2_py/scale.py,sha256=ufYdBhtEv-_KlXYFTzX6iHjS5fd0DTmR1VpE02gSLb8,82254
31
+ ggplot2_py/stat.py,sha256=airtZLlQMoOAMnrn62DoQSMHzAMf8zVEQBQdldl8iWQ,167192
32
+ ggplot2_py/theme.py,sha256=23cbJ64wkfFyw4g474yBFzjFBLtKp3vv61iDdsUA64I,13546
33
+ ggplot2_py/theme_defaults.py,sha256=iA_kJBjjzLpsG7vHzEL5ma7t_9INiy2e6XXtZCfWH68,36311
34
+ ggplot2_py/theme_elements.py,sha256=2e6hMWbLNMPCMqzjlyS1bH6XL5l22EqxdMwKQuqTyw0,63580
35
+ ggplot2_py/coords/__init__.py,sha256=EB2z4ocd6jRlf2f95-_F8xD4aLvf2QFMmqos2PUixiw,834
36
+ ggplot2_py/geoms/__init__.py,sha256=iUCIceJbLSD4TjOtBLCn-8BK2jHVyIJBVYfjTt9BdIA,293
37
+ ggplot2_py/guides/__init__.py,sha256=YPw0bfL6l-xpduIJuwPcq4KVtnJVgOqLcYHzxTh-Fbc,204
38
+ ggplot2_py/resources/diamonds.csv,sha256=lXRzCwOrokHYmcSpdRHFBhsZNY-riVEHdPtsJBaDRcQ,2772143
39
+ ggplot2_py/resources/economics.csv,sha256=BQvcE7wWyfny4D6pB0xP5HHmH_mRjDCqRIuGR_M4GUc,22131
40
+ ggplot2_py/resources/economics_long.csv,sha256=zx_EiNCtKlwl0HEYcv6KoTCAddDumE9cYbYpxCZUCKM,123547
41
+ ggplot2_py/resources/faithfuld.csv,sha256=U2LleBDYmogQb_kDeil2v__YHUCubh8bgzFjyrOdIg4,298297
42
+ ggplot2_py/resources/luv_colours.csv,sha256=L-c3aEHMJPZNcdDKqqU0b90W5FM4UtbEe-Np29LOKRQ,39004
43
+ ggplot2_py/resources/midwest.csv,sha256=FOhp7_w4R-gHqCZJlM5c59-RNbiV07WaIt881IKPt0A,98022
44
+ ggplot2_py/resources/mpg.csv,sha256=FpX7FxpCJOxfkCZS9ghMRr1Sisv1Anj4O6gQTON0Mzw,16046
45
+ ggplot2_py/resources/msleep.csv,sha256=Cm5ArhLjOFXbU5Ubo3slSyZgv36TCjMECQY9L9dY2GM,6773
46
+ ggplot2_py/resources/presidential.csv,sha256=-IVpCt0WvBwYerzte6KOaDBpThxj2GIx49ChOoRcdfk,555
47
+ ggplot2_py/resources/seals.csv,sha256=VEuSEBLz3Fj14eBdM6hp6M6GpH2lqN5ekT_d2Mk1rK0,57035
48
+ ggplot2_py/resources/txhousing.csv,sha256=RdHoH5W9bud_DzsefIc8yNOFaxMl6IDDKMiP68aoIoY,523993
49
+ ggplot2_py/scales/__init__.py,sha256=n1NLGW0cOeFxOYkj_yS2rvec4p9N1ZJBsugPG2TOHgY,100013
50
+ ggplot2_py/stats/__init__.py,sha256=X_WSwq3jS2iJPGy7jEu_tXSQvVrIvC-5pm4ag2qTLVI,222
51
+ ggplot2_python-4.0.2.9000.dist-info/METADATA,sha256=XlPN5apyiqjKVSHhnC7dJyKzRxjthLK8K2BTMvCIUzY,8231
52
+ ggplot2_python-4.0.2.9000.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
53
+ ggplot2_python-4.0.2.9000.dist-info/licenses/LICENSE,sha256=E0GJjw07cYRmJYj_8UZKbhevWQ-Swd3nVR6qBddvz9c,39
54
+ ggplot2_python-4.0.2.9000.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ # MIT
2
+
3
+ See DESCRIPTION from R package.