gg4py 0.1.0__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.
- gg4py/__init__.py +96 -0
- gg4py/diff.py +25 -0
- gg4py/io.py +27 -0
- gg4py/ir.py +25 -0
- gg4py-0.1.0.dist-info/METADATA +170 -0
- gg4py-0.1.0.dist-info/RECORD +116 -0
- gg4py-0.1.0.dist-info/WHEEL +4 -0
- gg4py-0.1.0.dist-info/licenses/LICENSE +21 -0
- ggcore/__init__.py +57 -0
- ggcore/aes.py +314 -0
- ggcore/align.py +986 -0
- ggcore/annotations.py +416 -0
- ggcore/arrow.py +184 -0
- ggcore/axis.py +1085 -0
- ggcore/axis_guide.py +2083 -0
- ggcore/build.py +1607 -0
- ggcore/cli/__init__.py +23 -0
- ggcore/components.py +190 -0
- ggcore/composition.py +2057 -0
- ggcore/contour.py +430 -0
- ggcore/coord.py +2435 -0
- ggcore/data.py +285 -0
- ggcore/device.py +120 -0
- ggcore/eval.py +997 -0
- ggcore/facet.py +2084 -0
- ggcore/fills.py +445 -0
- ggcore/geom/__init__.py +237 -0
- ggcore/geom/annotation.py +253 -0
- ggcore/geom/bar.py +545 -0
- ggcore/geom/base.py +620 -0
- ggcore/geom/boxplot.py +431 -0
- ggcore/geom/dist.py +859 -0
- ggcore/geom/interval.py +397 -0
- ggcore/geom/line.py +413 -0
- ggcore/geom/point.py +260 -0
- ggcore/geom/polygon.py +491 -0
- ggcore/geom/rect.py +395 -0
- ggcore/geom/scene.py +3023 -0
- ggcore/geom/segment.py +425 -0
- ggcore/geom/sf.py +590 -0
- ggcore/geom/smooth.py +118 -0
- ggcore/geom/stat2d.py +98 -0
- ggcore/geom/text.py +834 -0
- ggcore/grobs.py +2572 -0
- ggcore/gtable.py +684 -0
- ggcore/guide.py +4110 -0
- ggcore/hexbin.py +222 -0
- ggcore/io.py +597 -0
- ggcore/ir/__init__.py +95 -0
- ggcore/ir/_cbor.py +205 -0
- ggcore/ir/codec.py +581 -0
- ggcore/ir/demo.py +101 -0
- ggcore/ir/errors.py +28 -0
- ggcore/ir/nodes.py +1248 -0
- ggcore/kde2d.py +159 -0
- ggcore/layer.py +289 -0
- ggcore/legend_draw.py +480 -0
- ggcore/loess.py +522 -0
- ggcore/map_data.py +225 -0
- ggcore/map_data_usa.py +7277 -0
- ggcore/metrics/__init__.py +100 -0
- ggcore/metrics/catalog.py +147 -0
- ggcore/metrics/data/metrics_table_v2.bin +0 -0
- ggcore/metrics/data/metrics_table_v2.json +214 -0
- ggcore/metrics/data/rules.json +62 -0
- ggcore/metrics/data/scripts.json +795 -0
- ggcore/metrics/faces.py +212 -0
- ggcore/metrics/fallback.py +171 -0
- ggcore/metrics/provider.py +220 -0
- ggcore/metrics/rules.py +43 -0
- ggcore/metrics/runs.py +216 -0
- ggcore/metrics/table.py +299 -0
- ggcore/munch.py +33 -0
- ggcore/palette_data.py +676 -0
- ggcore/palettes.py +895 -0
- ggcore/perf.py +521 -0
- ggcore/plot.py +513 -0
- ggcore/plot_gtable.py +1011 -0
- ggcore/plotmath.py +450 -0
- ggcore/plotspec.py +668 -0
- ggcore/png.py +52 -0
- ggcore/position.py +1226 -0
- ggcore/registry.py +1850 -0
- ggcore/scale_specs.py +228 -0
- ggcore/scales.py +3476 -0
- ggcore/scales_date.py +662 -0
- ggcore/script.py +332 -0
- ggcore/sf.py +1427 -0
- ggcore/sf_stat.py +140 -0
- ggcore/stat.py +1806 -0
- ggcore/stat2d.py +805 -0
- ggcore/stat_longtail.py +2024 -0
- ggcore/theme.py +2654 -0
- ggcore/units.py +1010 -0
- ggcore/viewport.py +1415 -0
- ggdiff/__init__.py +37 -0
- ggdiff/cli.py +353 -0
- ggdiff/compare.py +148 -0
- ggdiff/image.py +59 -0
- ggdiff/raster.py +100 -0
- ggdiff/report.py +79 -0
- ggdiff/svgimage.py +144 -0
- ggdiff/svgtext.py +313 -0
- ggio/__init__.py +13 -0
- ggio/csv.py +114 -0
- ggio/frame.py +487 -0
- ggshape/__init__.py +13 -0
- ggshape/harfbuzz.py +157 -0
- ggskia/__init__.py +75 -0
- ggskia/cli/__init__.py +1 -0
- ggskia/cli/ggsave.py +189 -0
- ggskia/cli/render.py +150 -0
- ggskia/curves.py +431 -0
- ggskia/pch.py +225 -0
- ggskia/skia.py +1434 -0
- ggskia/text.py +389 -0
gg4py/__init__.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""gg4py — 面向用户的顶层入口:一条 `import` 拿到 `library(ggplot2)` 能用的名字。
|
|
2
|
+
|
|
3
|
+
import gg4py
|
|
4
|
+
|
|
5
|
+
p = gg4py.ggplot(df, gg4py.aes(x="wt", y="mpg")) + gg4py.geom_point()
|
|
6
|
+
gg4py.ggsave(p, "out.png", width=6, height=4, dpi=150)
|
|
7
|
+
|
|
8
|
+
三层边界(提升策略与迁移示例见 `docs/notes/public-api.md`):
|
|
9
|
+
|
|
10
|
+
- **顶层**(本模块):`ggcore.plot.__all__` 的**投影**——注册表里每个 `geom_*` /
|
|
11
|
+
`stat_*` / `scale_*` / `coord_*` / `facet_*` / `theme_*`,加上 `ggplot` / `aes` /
|
|
12
|
+
`labs` / `guides` 等静态名字;再补上输入适配的 `from_*` / `to_column_table`、
|
|
13
|
+
`ggsave` 与 `__version__`。名字**不手抄**:`__all__` 每次从
|
|
14
|
+
`ggcore.plot.__all__` 现算,新登记的组件自动出现在顶层
|
|
15
|
+
(`tests/test_public_api.py` 守着这条)。
|
|
16
|
+
- **子命名空间**:`gg4py.io` / `gg4py.ir` / `gg4py.diff` —— IR、codec、差分这类
|
|
17
|
+
开发者 API,首次访问时才导入。
|
|
18
|
+
- **内部包**:`ggcore.*` / `ggio` / `ggshape` / `ggskia` / `ggdiff` 路径与导出
|
|
19
|
+
完全不变,高级入口、既有文档与扩展写法不受影响。
|
|
20
|
+
|
|
21
|
+
X1 门禁不允许 `ggcore` import `ggskia`,所以 `ggsave`(唯一需要渲染后端的顶层
|
|
22
|
+
名字)由模块级 `__getattr__` 惰性取:没有 skia-python / uharfbuzz 的环境里
|
|
23
|
+
`import gg4py` 仍然成功,`gg4py.ggsave` 回落到 `ggcore.io.ggsave`,调用时才报
|
|
24
|
+
「没有后端」。
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import importlib
|
|
30
|
+
from typing import Any
|
|
31
|
+
|
|
32
|
+
import ggcore.plot as _plot
|
|
33
|
+
from ggcore import __version__ as _core_version
|
|
34
|
+
from ggio import frame as _frame
|
|
35
|
+
|
|
36
|
+
__version__ = _core_version
|
|
37
|
+
|
|
38
|
+
#: 顶层补充的输入适配名。与 `ggio.frame.__all__` 同源:只提升可调用的入口,
|
|
39
|
+
#: `SUPPORTED_INPUTS` 这类说明性常量留给 `ggio.frame`。
|
|
40
|
+
_ADAPTERS: tuple[str, ...] = tuple(
|
|
41
|
+
name for name in _frame.__all__ if callable(getattr(_frame, name))
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
#: 需要渲染后端的名字 → 提供它的模块。`ggcore` 不能 import 它们(X1),
|
|
45
|
+
#: 所以只能惰性取。
|
|
46
|
+
_LAZY: dict[str, str] = {"ggsave": "ggskia"}
|
|
47
|
+
|
|
48
|
+
#: 开发者 API 的子命名空间,首次访问时才导入(`gg4py.diff` 会拉 numpy / pillow)。
|
|
49
|
+
_SUBMODULES: tuple[str, ...] = ("diff", "io", "ir")
|
|
50
|
+
|
|
51
|
+
_MISSING = object()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _public_names() -> list[str]:
|
|
55
|
+
"""顶层导出名:`ggcore.plot.__all__` 现算 + 少量补充名,顺序稳定且不重复。"""
|
|
56
|
+
names = list(_plot.__all__)
|
|
57
|
+
for name in (*_ADAPTERS, *_LAZY, "__version__"):
|
|
58
|
+
if name not in names:
|
|
59
|
+
names.append(name)
|
|
60
|
+
return names
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _lazy_entry(name: str, provider: str) -> Any:
|
|
64
|
+
"""从渲染后端取一个顶层名字;后端缺席时回落到设备无关的 `ggcore.io`。"""
|
|
65
|
+
try:
|
|
66
|
+
module = importlib.import_module(provider)
|
|
67
|
+
except ModuleNotFoundError as exc:
|
|
68
|
+
# 只兜「渲染栈根本不在这台机器上」:`ggskia` 自己的 bug 照旧抛出。
|
|
69
|
+
if exc.name not in {"ggskia", "skia"}:
|
|
70
|
+
raise
|
|
71
|
+
from ggcore.io import ggsave
|
|
72
|
+
|
|
73
|
+
return ggsave
|
|
74
|
+
return getattr(module, name)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def __getattr__(name: str) -> Any:
|
|
78
|
+
if name == "__all__":
|
|
79
|
+
# 不落进模块 `__dict__`:每次访问都重算,注册表一变顶层立刻跟上。
|
|
80
|
+
return _public_names()
|
|
81
|
+
if name in _LAZY:
|
|
82
|
+
return _lazy_entry(name, _LAZY[name])
|
|
83
|
+
if name in _SUBMODULES:
|
|
84
|
+
module = importlib.import_module(f".{name}", __name__)
|
|
85
|
+
globals()[name] = module
|
|
86
|
+
return module
|
|
87
|
+
if name in _ADAPTERS:
|
|
88
|
+
return getattr(_frame, name)
|
|
89
|
+
value = getattr(_plot, name, _MISSING)
|
|
90
|
+
if value is not _MISSING:
|
|
91
|
+
return value
|
|
92
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def __dir__() -> list[str]:
|
|
96
|
+
return sorted(set(globals()) | set(_public_names()) | set(_SUBMODULES))
|
gg4py/diff.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""`gg4py.diff` — 参考图 × 实测图的差分(开发者 / 对拍入口)。
|
|
2
|
+
|
|
3
|
+
import gg4py.diff
|
|
4
|
+
|
|
5
|
+
result = gg4py.diff.compare_images(expected_png, current_png)
|
|
6
|
+
gg4py.diff.rasterize_svg("expected.svg", "expected.png", dpi=72)
|
|
7
|
+
|
|
8
|
+
只有转发:名字与 `ggdiff.__all__` 同源。`numpy` 在导入时就会被拉起,
|
|
9
|
+
`pillow` 只在真正读写位图时用到。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
import ggdiff as _diff
|
|
17
|
+
|
|
18
|
+
__all__ = list(_diff.__all__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __getattr__(name: str) -> Any:
|
|
22
|
+
try:
|
|
23
|
+
return getattr(_diff, name)
|
|
24
|
+
except AttributeError:
|
|
25
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
gg4py/io.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""`gg4py.io` — IR 落盘与 `ggsave` 的开发者入口(不需要 skia)。
|
|
2
|
+
|
|
3
|
+
import gg4py.io
|
|
4
|
+
|
|
5
|
+
gg4py.io.save_ir(p, "plot.ggir.cbor") # 同一张图 → IR
|
|
6
|
+
gg4py.io.export_ir_json(p, "plot.ir.json") # 调试视图
|
|
7
|
+
gg4py.io.ggsave(p, "plot.png") # 需要已注册的渲染后端
|
|
8
|
+
|
|
9
|
+
只有转发:名字与 `ggcore.io.__all__` 同源。常规出图用顶层 `gg4py.ggsave`
|
|
10
|
+
(它会惰性导入 `ggskia` 并注册后端);这里保留设备无关的编排与
|
|
11
|
+
`register_backend` / `save_ir` 这类扩展钩子。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import ggcore.io as _io
|
|
19
|
+
|
|
20
|
+
__all__ = list(_io.__all__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __getattr__(name: str) -> Any:
|
|
24
|
+
try:
|
|
25
|
+
return getattr(_io, name)
|
|
26
|
+
except AttributeError:
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
gg4py/ir.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""`gg4py.ir` — IR v0 的开发者入口(节点类型、CBOR codec)。
|
|
2
|
+
|
|
3
|
+
import gg4py.ir
|
|
4
|
+
|
|
5
|
+
blob = gg4py.ir.encode(gg4py.ir.demo_scene())
|
|
6
|
+
scene = gg4py.ir.decode(blob)
|
|
7
|
+
|
|
8
|
+
只有转发:名字与 `ggcore.ir.__all__` 同源。普通用户不需要它;
|
|
9
|
+
`gg4py.io.save_ir` 已把「一张图 → IR 文件」包好了。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
import ggcore.ir as _ir
|
|
17
|
+
|
|
18
|
+
__all__ = list(_ir.__all__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __getattr__(name: str) -> Any:
|
|
22
|
+
try:
|
|
23
|
+
return getattr(_ir, name)
|
|
24
|
+
except AttributeError:
|
|
25
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gg4py
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python port of ggplot2 4.0.3: the grammar of graphics, its own IR, skia and DOM SVG renderers
|
|
5
|
+
Project-URL: Homepage, https://github.com/SilenWang/gg4py
|
|
6
|
+
Project-URL: Repository, https://github.com/SilenWang/gg4py
|
|
7
|
+
Project-URL: Issues, https://github.com/SilenWang/gg4py/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/SilenWang/gg4py/blob/main/docs/README.md
|
|
9
|
+
Author: Sylens Wong
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ggplot2,grammar-of-graphics,plotting,skia,visualization
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: cbor2<7,>=6.1.5
|
|
21
|
+
Requires-Dist: contourpy<1.4,>=1.3.3
|
|
22
|
+
Requires-Dist: numpy<3,>=2.5.4
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: pandas<4,>=3.1; extra == 'all'
|
|
25
|
+
Requires-Dist: pillow<14,>=11; extra == 'all'
|
|
26
|
+
Requires-Dist: pyarrow<27,>=26; extra == 'all'
|
|
27
|
+
Requires-Dist: skia-python<145,>=144.1; extra == 'all'
|
|
28
|
+
Requires-Dist: uharfbuzz<0.58,>=0.57; extra == 'all'
|
|
29
|
+
Provides-Extra: data
|
|
30
|
+
Requires-Dist: pandas<4,>=3.1; extra == 'data'
|
|
31
|
+
Requires-Dist: pyarrow<27,>=26; extra == 'data'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: build<2,>=1.3; extra == 'dev'
|
|
34
|
+
Requires-Dist: pandas<4,>=3.1; extra == 'dev'
|
|
35
|
+
Requires-Dist: pillow<14,>=11; extra == 'dev'
|
|
36
|
+
Requires-Dist: playwright<2,>=1.64.1; extra == 'dev'
|
|
37
|
+
Requires-Dist: pyarrow<27,>=26; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-benchmark<6,>=5.2; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest<10,>=9.2; extra == 'dev'
|
|
40
|
+
Requires-Dist: ruff<0.18,>=0.17.3; extra == 'dev'
|
|
41
|
+
Requires-Dist: skia-python<145,>=144.1; extra == 'dev'
|
|
42
|
+
Requires-Dist: twine<8,>=7; extra == 'dev'
|
|
43
|
+
Requires-Dist: uharfbuzz<0.58,>=0.57; extra == 'dev'
|
|
44
|
+
Provides-Extra: diff
|
|
45
|
+
Requires-Dist: pillow<14,>=11; extra == 'diff'
|
|
46
|
+
Provides-Extra: render
|
|
47
|
+
Requires-Dist: skia-python<145,>=144.1; extra == 'render'
|
|
48
|
+
Requires-Dist: uharfbuzz<0.58,>=0.57; extra == 'render'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# gg4py
|
|
52
|
+
|
|
53
|
+
A Python port of **ggplot2 4.0.3** — the grammar of graphics rebuilt from scratch, with its
|
|
54
|
+
own intermediate representation and its own renderers (skia → PNG/SVG/PDF on the desktop,
|
|
55
|
+
TypeScript + DOM SVG in the browser). It is **not** a wrapper around matplotlib, plotnine or
|
|
56
|
+
any other plotting system: the grammar core depends on `numpy` alone.
|
|
57
|
+
|
|
58
|
+
中文版:[README.zh-CN.md](README.zh-CN.md)
|
|
59
|
+
|
|
60
|
+
## Install and first plot
|
|
61
|
+
|
|
62
|
+
Dependencies, environments and tasks are managed by [pixi](https://pixi.sh) (`pixi.toml`),
|
|
63
|
+
so there is nothing to `pip install`. Linux x86-64 for now.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pixi install
|
|
67
|
+
pixi run ggsave examples/heatmap/plot.py:plot my-first-plot.png
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`ggsave` picks the device from the extension (`.png`, `.svg`, `.pdf`). The same plot from
|
|
71
|
+
Python — the data is any dict of columns, a pandas DataFrame or an Arrow table. One import
|
|
72
|
+
brings in the whole `library(ggplot2)` surface:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import gg4py # ggplot, aes, every geom_*/stat_*/scale_*, from_*, ggsave
|
|
76
|
+
|
|
77
|
+
df = gg4py.from_dict({"wt": [1.9, 2.6, 3.2, 3.5, 4.1], "mpg": [31, 26, 21, 18, 15]})
|
|
78
|
+
p = (
|
|
79
|
+
gg4py.ggplot(df, gg4py.aes(x="wt", y="mpg"))
|
|
80
|
+
+ gg4py.geom_point(size=2)
|
|
81
|
+
+ gg4py.labs(title="First plot")
|
|
82
|
+
)
|
|
83
|
+
gg4py.ggsave(p, "first-plot.png", width=6, height=4, dpi=150)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Module boundaries — `gg4py.io` / `gg4py.ir` / `gg4py.diff` for IR, codecs and diffing —
|
|
87
|
+
are spelled out in [`docs/notes/public-api.md`](docs/notes/public-api.md); the old
|
|
88
|
+
`from ggcore.plot import …` paths keep working unchanged.
|
|
89
|
+
|
|
90
|
+
## What it draws
|
|
91
|
+
|
|
92
|
+
Four examples, each a self-contained `plot.py` using nothing but gg4py itself
|
|
93
|
+
(`pixi run examples:<name>` regenerates the files below). Skipped references and the
|
|
94
|
+
capabilities they need are listed in [`docs/examples.md`](docs/examples.md).
|
|
95
|
+
|
|
96
|
+
**[Heatmap](examples/heatmap/plot.py)** — `geom_tile` + a viridis gradient over a
|
|
97
|
+
12-month × 8-year grid of synthetic temperatures.
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
**[Bump chart](examples/bump-chart/plot.py)** — `geom_line` + `geom_point` with
|
|
102
|
+
`scale_y_reverse()`, so rank 1 sits at the top and crossings stay readable.
|
|
103
|
+
|
|
104
|
+

|
|
105
|
+
|
|
106
|
+
**[Circular barplot with groups](examples/circular-barplot/plot.py)** — bars on a continuous
|
|
107
|
+
axis with a gap between groups, rolled into a ring by `coord_polar()`.
|
|
108
|
+
|
|
109
|
+

|
|
110
|
+
|
|
111
|
+
**[Mirrored density](examples/mirrored-density/plot.py)** — two densities sharing a zero
|
|
112
|
+
baseline: one drawn from `after_stat("density")`, the other from `after_stat("-density")`.
|
|
113
|
+
|
|
114
|
+

|
|
115
|
+
|
|
116
|
+
## How it works
|
|
117
|
+
|
|
118
|
+
| Layer | Responsibility |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `src/ggcore/` | The grammar: aes, stats, geoms, scales, coords, facets, guides, themes. Pure Python + numpy, no pandas, no plotting library. Also runs in the browser under Pyodide. |
|
|
121
|
+
| IR (`ggcore.ir`) | Resolved geometry in float32 buffers, serialized as canonical CBOR. The single hand-off between the core and every renderer. |
|
|
122
|
+
| `src/ggio/` | Input adapters: pandas / Arrow / dict of arrays → one columnar table. |
|
|
123
|
+
| `src/ggskia/` | skia-python device → PNG / SVG / PDF for desktop and server rendering. |
|
|
124
|
+
| `web/viewer/` | TypeScript + DOM SVG viewer for the browser — no wasm, no bundler. |
|
|
125
|
+
| `web/editor/` | Browser code editor: CodeMirror 6 + Pyodide execution + the same DOM SVG renderer, plus SVG / PNG / JPG export. One static page, no backend ([docs/notes/editor.md](docs/notes/editor.md)). |
|
|
126
|
+
| `src/ggdiff/` | Differential testing: R reference vs. our output, one rasterizer (resvg), pixel and ink metrics. |
|
|
127
|
+
|
|
128
|
+
The core is checked, not just claimed: X1 gates forbid any import outside
|
|
129
|
+
`numpy`/stdlib/`contourpy` inside `ggcore`, and the same plot produces byte-identical IR on
|
|
130
|
+
CPython and Pyodide. Rendering parity is measured against 311 upstream SVG snapshots
|
|
131
|
+
generated by ggplot2 4.0.3 itself, plus the browser viewer's DOM output.
|
|
132
|
+
|
|
133
|
+
## Development
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
pixi run check # lint + tests + gates + viewer parity (what CI runs)
|
|
137
|
+
pixi run test # pytest
|
|
138
|
+
pixi run lint # ruff check + ruff format --check
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Layout, environments and the full task catalogue: [`docs/dev/layout.md`](docs/dev/layout.md).
|
|
142
|
+
User guide (one page per module, every snippet executed by `pixi run docs:guide`):
|
|
143
|
+
[`docs/guide/`](docs/guide/index.md) — start with the
|
|
144
|
+
[R → Python mapping](docs/guide/r-to-python.md) if you come from ggplot2.
|
|
145
|
+
Reference reading (module-by-module contracts, gates, snapshot policy): [`docs/README.md`](docs/README.md).
|
|
146
|
+
|
|
147
|
+
## How this was built
|
|
148
|
+
|
|
149
|
+
Every design decision, line of code, test and doc page here was produced by a **single
|
|
150
|
+
model — DeepSeek** ([deepseek-ai](https://github.com/deepseek-ai)) — working through
|
|
151
|
+
open-source agent tooling:
|
|
152
|
+
|
|
153
|
+
- [OpenCode](https://github.com/anomalyco/opencode) — terminal coding agent
|
|
154
|
+
- [Reasonix](https://github.com/esengine/DeepSeek-Reasonix) — coding agent
|
|
155
|
+
- [Codex](https://github.com/openai/codex) — OpenAI's terminal coding agent
|
|
156
|
+
- [Multica](https://github.com/multica-ai/multica) — issue board and agent orchestration
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT — see [`LICENSE`](LICENSE). © 2026 Sylens Wong.
|
|
161
|
+
|
|
162
|
+
## Attribution
|
|
163
|
+
|
|
164
|
+
gg4py is a Python port of [ggplot2](https://github.com/tidyverse/ggplot2) **4.0.3**
|
|
165
|
+
(commit `cc1444c10edb87650fbe0cb31d56f0da1a255634`, tag `v4.0.3`), © 2025 ggplot2 core
|
|
166
|
+
developer team, MIT. The grammar semantics, the R-side reference fixtures and the reference
|
|
167
|
+
plots in `docs/cases/` are ported from or generated by that project; its copyright notice is
|
|
168
|
+
reproduced here, as the MIT license requires. Third-party asset inventory:
|
|
169
|
+
[`docs/notes/licenses.md`](docs/notes/licenses.md) (fonts, wasm and browsers are fetched at
|
|
170
|
+
build time by pixi / npm, never committed).
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
gg4py/__init__.py,sha256=uxOzow9AknpEr6MocEu3z7ZnRIx-ngd3tH3JuK22Rdg,3838
|
|
2
|
+
gg4py/diff.py,sha256=bbarAH-KQL-RDnP3nLK9GfIkkUZTddrEkHPzqvTjLBo,698
|
|
3
|
+
gg4py/io.py,sha256=_J_-YR2A0XP17TdUVi_fWusbmjDKibWPxdyyfPMqczs,865
|
|
4
|
+
gg4py/ir.py,sha256=YyyjFbR57UaWfAwzYcUdFhd9xXJA3Hk9PoPAIEo6Y7s,647
|
|
5
|
+
ggcore/__init__.py,sha256=b-S3Js1Fy5TR8o6sWENIwGiM8BBjetx3vtFcp4vIuqI,1901
|
|
6
|
+
ggcore/aes.py,sha256=hT0goIOtQzmtE0GgZDn9lo2cEl9YlKfK0KYYVn-BflU,11763
|
|
7
|
+
ggcore/align.py,sha256=3UAafIE8etCTrxxyGhiGJ6oOH2bPNbjU-zGNEktZM-Q,38827
|
|
8
|
+
ggcore/annotations.py,sha256=ctgF6c2cag55yphg3xdVc2jidk0ZHk2BLK1otP0KFvo,14724
|
|
9
|
+
ggcore/arrow.py,sha256=hihCQIx3omiJ_9zbaG8S6hlvx4kTmIfvL-lZRM2e_mE,6924
|
|
10
|
+
ggcore/axis.py,sha256=wL0ueSGgJuJrlAWmVKPCxuFViNuw-UuNlxESgfljb-k,43109
|
|
11
|
+
ggcore/axis_guide.py,sha256=RBPIMC7VevOETa6uwG-iD1k66kn1atcYfCuzmmjDPag,84274
|
|
12
|
+
ggcore/build.py,sha256=LzZu1ehRsfr6Doimay5UE-KFOKlNnZhpc4vDleLC_JY,67528
|
|
13
|
+
ggcore/components.py,sha256=7m-69CNZkDYtpt3dQPRLz3cQP6P6xkOKct5BphE3JNk,6770
|
|
14
|
+
ggcore/composition.py,sha256=WF52POebNAR6PBrAkAbSdmgKFuOc7tYWvM54H9icFz8,79060
|
|
15
|
+
ggcore/contour.py,sha256=-4c5880LPYLPH0jnL4solPQ1BLI2pJaksDICW6Jnv5Y,16127
|
|
16
|
+
ggcore/coord.py,sha256=msQdJRMvRZEaVjsbftoUnWwatIyi_mJX_uLdYPftajg,103386
|
|
17
|
+
ggcore/data.py,sha256=BuQU7mXwrN3rf2yBK4MZvoOm5UAn_3NB2dNATe2UPVE,11131
|
|
18
|
+
ggcore/device.py,sha256=qmVkoZH8HGxqUM6H6M900_nqQ9738BjTU_lmAisgPdE,4443
|
|
19
|
+
ggcore/eval.py,sha256=Nd7g5Y9O9WpiEbrGtWDvwUsrBgrsiNL5taJA43KticI,38061
|
|
20
|
+
ggcore/facet.py,sha256=yfHlqOG1AxQpUMovTKlOM5LQH17IVN-Wh1RYv32Du-o,84998
|
|
21
|
+
ggcore/fills.py,sha256=4YscIlTPtJdp2t-JYFUiiP1kXw9ctvFp48TtEmx35MI,16048
|
|
22
|
+
ggcore/grobs.py,sha256=dbEvbhvO3UntxP0cxl3pf4AOa_SwxUtz0MfNIMlQjJg,99004
|
|
23
|
+
ggcore/gtable.py,sha256=FW-kVgS8-76awPMw0xYXl02R53J-0hRRnWDOYqa0Jck,24288
|
|
24
|
+
ggcore/guide.py,sha256=tSdQDxn5g2p_duRMQagVFmEDSZ3LERHoIhYq_p47s18,157681
|
|
25
|
+
ggcore/hexbin.py,sha256=CE6KgW-N_U_AoAttOGwiA1Ab_9612pWO7o3HuZcMJ1k,8362
|
|
26
|
+
ggcore/io.py,sha256=UoMT4z7fCU6V-hED6ZLF5YVTkK6nRrCiO5b45pIfLIA,22239
|
|
27
|
+
ggcore/kde2d.py,sha256=3350M2eElGrBo7KjOOonBJP-oFTOJ6An2_9TcZYUaHM,5892
|
|
28
|
+
ggcore/layer.py,sha256=2FdusBSuo8ds_xskH1zDz4JMBuWsf_pL7He7EVLzRHM,11881
|
|
29
|
+
ggcore/legend_draw.py,sha256=gvyVLqg4R6krSQTl6aiwoTDgqLeRE0nVXn9Cn5W6krE,14804
|
|
30
|
+
ggcore/loess.py,sha256=DlYG3d4SER7C61qWE9pNE3Wn7FuJ32BmjzR_qVqd1LI,19149
|
|
31
|
+
ggcore/map_data.py,sha256=lYElf6ei9vH3LvF9XB7RDHGGSONGCF4wH6F_YdEgsNQ,6625
|
|
32
|
+
ggcore/map_data_usa.py,sha256=6TQlu55ON124xo5CC1CWES06LKVTjyxu37Rvmmmiuww,212028
|
|
33
|
+
ggcore/munch.py,sha256=920CzsUhz27CRweXiZeD18JvPTUpjW0WUzJJ6lKadW0,1626
|
|
34
|
+
ggcore/palette_data.py,sha256=Q5dXiQBuwkrqpObQLtedsTTcqh2ut5OA9n9rAb0JgUc,49380
|
|
35
|
+
ggcore/palettes.py,sha256=6gWwwrxEIvu0abAH0-qsxOsvNjoIxwilS4uj0rBleCE,31066
|
|
36
|
+
ggcore/perf.py,sha256=dM_FXOEhGSLuiU9pbmjfLmZ6_EscIuSWJ-gw61t1WIY,19189
|
|
37
|
+
ggcore/plot.py,sha256=OaYluvejVrOZohY8T2Y2Jv0GZRPtkxMNaIlGLvcW0vE,21319
|
|
38
|
+
ggcore/plot_gtable.py,sha256=klriFNtif_nkUdg4N1don88E5XROFLvuCI0WHfddzlE,37183
|
|
39
|
+
ggcore/plotmath.py,sha256=0HH7UkEPGJRKIAFCZuILt5ixJN5761ptF38zyrA06rI,14999
|
|
40
|
+
ggcore/plotspec.py,sha256=FIgTcNQFJI3TUB_iOacFP4RUSLgGshwSdOkXLX5WR0k,25601
|
|
41
|
+
ggcore/png.py,sha256=BWqUnO3MJBpA4Ju5Ds-NerlPh1Xv1cD-_sNs1XUIJLQ,1813
|
|
42
|
+
ggcore/position.py,sha256=Q7I5vQfKsQT4GVlKfhO8rVxcoBu-itvxnhf3xtP3K2Q,49834
|
|
43
|
+
ggcore/registry.py,sha256=_bZU6uFkiMg7X9_hEwVyTDO_-LYagyfQrzyuq06SLR8,65639
|
|
44
|
+
ggcore/scale_specs.py,sha256=0OUyOoSvAVVVNz5TuQn3qZhHvghtf2vsZab1Xcy8JSY,10967
|
|
45
|
+
ggcore/scales.py,sha256=itlvnuMByb7wMZw7bye_IannTbfje-JF6g_1Bf0IesY,144751
|
|
46
|
+
ggcore/scales_date.py,sha256=-vghGUBWqztDE2GBvgCD4agrubdHrQK9ZC7RDi6AdTA,23515
|
|
47
|
+
ggcore/script.py,sha256=g0T83gpRIGkBiJYiZYZ2-ub5aqmnHtHG7VVfEKnLVbs,12478
|
|
48
|
+
ggcore/sf.py,sha256=FQ6NWWfQuTL7W6FqASLZZ_IPKrEMfLzk6kT6ZkvfRZs,52304
|
|
49
|
+
ggcore/sf_stat.py,sha256=raMD3M8NEmKDlDYnrvnDNL216TZAiUgeodzkHih96eQ,5316
|
|
50
|
+
ggcore/stat.py,sha256=HiFb0uMrm3MFYaSVZnp7_xTmGYBJGONH2EG63sDmq-U,70498
|
|
51
|
+
ggcore/stat2d.py,sha256=IXEcLIdWf1Wuq0QjjsRsB4ya2F9MwCqpMZGN2m6sDB4,31928
|
|
52
|
+
ggcore/stat_longtail.py,sha256=wXARkh29dvfoDpnNrE2RHXWy8qTGIdn1Web5eLkARMg,80451
|
|
53
|
+
ggcore/theme.py,sha256=VDAApN3iJ3phmnL9o_aHduqlAxPUDyA2409YVVLXo2I,97151
|
|
54
|
+
ggcore/units.py,sha256=Th_Sn63PwvbKsgAIpbZ7m-iGd6GT0ZCIa7WHsUoP8OE,36030
|
|
55
|
+
ggcore/viewport.py,sha256=zDdX50E15ykawFEg-i2R7-0ucnnyqFixErDO0LE2Bz0,54037
|
|
56
|
+
ggcore/cli/__init__.py,sha256=vRLfBVhv7JxqPXeUbxldoARXZK2GbRHXkr7Z3doetOQ,966
|
|
57
|
+
ggcore/geom/__init__.py,sha256=tI_uks5xzJKtVKjGxb5Qi69RIE04R3nvUKh95ldj8ic,7188
|
|
58
|
+
ggcore/geom/annotation.py,sha256=yri2UHNQFejO04kYU1flOkRmu8pUoYIuUXgfbA0IjfA,10166
|
|
59
|
+
ggcore/geom/bar.py,sha256=XBstQh6yOgW7ynk1LHV95T--EIxsKuYeeeLGMsjIk-Y,21955
|
|
60
|
+
ggcore/geom/base.py,sha256=Y23DhGCLQlRQqVn_aNZatvi8k7Y7MOdB66pdgvnK1W0,25890
|
|
61
|
+
ggcore/geom/boxplot.py,sha256=odToOTZPRWyIo7j4w9SxSbQRBwcTvl2LSfno0HrDkGc,19341
|
|
62
|
+
ggcore/geom/dist.py,sha256=lFr60fDdgOyHf5veE3N_labiDUV6jeIRR1whlqLUyz0,36007
|
|
63
|
+
ggcore/geom/interval.py,sha256=6aOYw5P8WTp7BD1Ok5AJYIvLhpZFqVS9FtrEF-wWUKk,16402
|
|
64
|
+
ggcore/geom/line.py,sha256=AmDQIR0_lV1P12II94YGJxvlImvZjPrTjmJ43pcBtMw,17146
|
|
65
|
+
ggcore/geom/point.py,sha256=_28g7rsk4frDbHguWtiSl0sASWLPHcGGkirWX42FWWg,10003
|
|
66
|
+
ggcore/geom/polygon.py,sha256=TGKGWFeD8_gR84b_WFGwpNjOkIyfzs4n0V2a1SI8lqk,18901
|
|
67
|
+
ggcore/geom/rect.py,sha256=oo_Tep_lMK1AL1lVWg5zAXq1Kj0xZuFPQdLOYssARE8,16338
|
|
68
|
+
ggcore/geom/scene.py,sha256=pJT5w83ZSa6ZS8HoigcY3M3CNrvF31QXrdQeeCKR5GI,122834
|
|
69
|
+
ggcore/geom/segment.py,sha256=eBT3fVpZxDZhIVkObGpe9sQ0gedmxUeDx6aItqPBZ3A,16746
|
|
70
|
+
ggcore/geom/sf.py,sha256=l-M81G-SO8CA_Kr9VUDA2MBqABaTKIVWPSB8zW74s4k,20876
|
|
71
|
+
ggcore/geom/smooth.py,sha256=j77Wya_BImz_FFp-b4pjO8SLkqqfXEedE9Exm_fIceA,4685
|
|
72
|
+
ggcore/geom/stat2d.py,sha256=_8HbMOAQW_Nz7k8-BEMwRwfDgl8gqe8RyD4uzPQ0I6k,3349
|
|
73
|
+
ggcore/geom/text.py,sha256=lFIiNzvdbupye_a-lUJAmBFl9wxe75CFhDWmUj9TF5E,32521
|
|
74
|
+
ggcore/ir/__init__.py,sha256=fjlY2i67DxzstuFeLBipnzhbWkO569ZwCpYf356Hhas,1824
|
|
75
|
+
ggcore/ir/_cbor.py,sha256=hJJt-X1wNoybnYckTSnPAh6utwYjJeokWrOOFyanEeQ,7542
|
|
76
|
+
ggcore/ir/codec.py,sha256=XBnrnsVDSg5jndMIbZ9QJmBaf20vSkSQaBPX7Pl0c7I,23525
|
|
77
|
+
ggcore/ir/demo.py,sha256=FGxkiHPa1w-F3dNbfCVTwSq9woY-mMgfZqjFaDBb9GA,3540
|
|
78
|
+
ggcore/ir/errors.py,sha256=pFma01QATQtZNRAARu22oikgV8Nb7gnylusNpggIOFg,897
|
|
79
|
+
ggcore/ir/nodes.py,sha256=3KLLNKhLBSaI6-92RYNbfJfgE0agqRMI8cGWRol8ggI,52325
|
|
80
|
+
ggcore/metrics/__init__.py,sha256=lkQFgFGCuekmlYTCG9zRcggMSkqursR9Sz_-RO-5mo4,2428
|
|
81
|
+
ggcore/metrics/catalog.py,sha256=xYtIhpdrZUdNxSEFJG6DmiN2uK8Nwd03Iq2wLk3AW_o,5111
|
|
82
|
+
ggcore/metrics/faces.py,sha256=BQVQhWq5PZ0q2o3OH9J8rdQI9sI3I2ddaRRlFLZKLr8,8566
|
|
83
|
+
ggcore/metrics/fallback.py,sha256=M3ui4l47xT_QGazr7NyG1K7QylVzSbhiH2Jd6-LRhCU,7898
|
|
84
|
+
ggcore/metrics/provider.py,sha256=Uu0DwiN3ZZg_e3y2WxzP1uoiaD81jA6Q7jUKQxn_FAY,8441
|
|
85
|
+
ggcore/metrics/rules.py,sha256=vlVk--2kcKvT8o53h5f29z8X2GVWaBmNwilOZzWx_eM,1786
|
|
86
|
+
ggcore/metrics/runs.py,sha256=o9zxKZjd9n3b157k5cKN2uAQdQiWKmLDxP8OB0Hb4bI,8585
|
|
87
|
+
ggcore/metrics/table.py,sha256=TLsVOtuABKFKIt1FeSOPnBFCF0twRJXGrWUm-BwGgCM,12877
|
|
88
|
+
ggcore/metrics/data/metrics_table_v2.bin,sha256=t_f8UBcurSBTzqMaGu539eXjkto2k5V-IiPpQCk74AM,102052
|
|
89
|
+
ggcore/metrics/data/metrics_table_v2.json,sha256=FIIHdlvEff8fBhRIdm8VoF9KmQ3FYIM2u1_cW42GQIk,3247
|
|
90
|
+
ggcore/metrics/data/rules.json,sha256=46KK1TyrtgH8Oh1R916yF6qXZ0l-NZQIgTqIILodfho,2642
|
|
91
|
+
ggcore/metrics/data/scripts.json,sha256=td-b-KZYZaJane5hpLApW7skPjVU04EwB2S0FR_1wgg,23258
|
|
92
|
+
ggdiff/__init__.py,sha256=eSAsXUovlCbw15LMkeQE6eeELxUmJg-L_ZbqyvtoS1w,1518
|
|
93
|
+
ggdiff/cli.py,sha256=MehIfi9pbX5PyKyhF66ijvS5LX-QF0F8-w-p7HtTZWU,13234
|
|
94
|
+
ggdiff/compare.py,sha256=d7XRJUOx1qqYgCDLGvlquguTW4ZbrRc-dwxuPXl9_HU,4823
|
|
95
|
+
ggdiff/image.py,sha256=53OtGFkGrBHUK33_0AKhuWb31e6tX7QXROxJfXAvgqQ,2178
|
|
96
|
+
ggdiff/raster.py,sha256=nPhOT-ECnGURuJJPW2vfNpwTaEeKWYczzHyvjqRs9VU,3508
|
|
97
|
+
ggdiff/report.py,sha256=pZFp8sADdhR3IRP1_NjJZiIcg9IZTP52PBXbbqv6r3s,2574
|
|
98
|
+
ggdiff/svgimage.py,sha256=wpIKCh7hUpH7CzT3vFHRCxARNHz6u_NFBWU65-1ZIvc,6159
|
|
99
|
+
ggdiff/svgtext.py,sha256=pvmeWg5vKjakAMnYjAiUuKXwwV_7UjbBVcCWz6JT0Xw,12511
|
|
100
|
+
ggio/__init__.py,sha256=mmwIYomJYS9swmHtKnSOkjIF5udnVC-O9Pa27a1w4LA,612
|
|
101
|
+
ggio/csv.py,sha256=RG71R4ERRtjIuzccCHzctPCSAH65rYUX9VqYW6kFuZA,4466
|
|
102
|
+
ggio/frame.py,sha256=NvP84TeqhQpYEhgXRVSpBRcw85GsncA7X3z-f430j_s,20423
|
|
103
|
+
ggshape/__init__.py,sha256=QS1890Hb9uezdY6CdTv2gzahX46qdnPxfB9Q9fwn_5w,612
|
|
104
|
+
ggshape/harfbuzz.py,sha256=GJC19NaeIvPyesWX5haJzv26q8GS3b475F9a0MOH2W4,6302
|
|
105
|
+
ggskia/__init__.py,sha256=LLu9XREhPi9AWwBJUsSxcgcxTZyVOJXn_vg0xMHmXq4,2408
|
|
106
|
+
ggskia/curves.py,sha256=OkONHJ3XRVUKAa8USA4gaxkPhPVlhhzXZedz8fPKRHc,15785
|
|
107
|
+
ggskia/pch.py,sha256=al8eqeHaojWYVPpUp163KL3aNUZVumPE47aR38Ppw8Q,8824
|
|
108
|
+
ggskia/skia.py,sha256=gAChBhsoNbkdFKC-jT_Mw-HF7j0homeMeINWOl0qrrY,63731
|
|
109
|
+
ggskia/text.py,sha256=BFHvd9jQ7eY8Sj4XDGjWNWlO7Jj3o3pVULqHTatzxSI,17126
|
|
110
|
+
ggskia/cli/__init__.py,sha256=YQK-HNLZukfyTh3LthR-M5IOgBqZJjwxYmtzJl7IBRs,57
|
|
111
|
+
ggskia/cli/ggsave.py,sha256=HMI4-SsiTzWzfysMbx0UzsU_hfEwCHXrSRfL3UNhofI,7111
|
|
112
|
+
ggskia/cli/render.py,sha256=xY7rj_a-UOZ2qkQ-lCr8gOhz9AbVbNd0NzbfDd1MW5g,5482
|
|
113
|
+
gg4py-0.1.0.dist-info/METADATA,sha256=-U3NEm3MJBSH5CmGw4T5D6VNm2fJyI2OYY_eFY66Ljg,7932
|
|
114
|
+
gg4py-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
115
|
+
gg4py-0.1.0.dist-info/licenses/LICENSE,sha256=iYIA8oXqxYyxwsZ9_UclMpUA49jNdIs0wCWUKch6PMI,1068
|
|
116
|
+
gg4py-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sylens Wong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ggcore/__init__.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""ggcore — gg4py 的语法核心(纯 Python,只依赖 numpy)。
|
|
2
|
+
|
|
3
|
+
这条边界由 X1 门禁强制:`src/ggcore/` 里只允许 import 标准库、numpy 和
|
|
4
|
+
CBOR 编码库;pandas / Arrow / 任何绘图库都必须留在包外(见
|
|
5
|
+
`tools/gates/check_import_whitelist.py` 与 `docs/notes/gates.md`)。
|
|
6
|
+
|
|
7
|
+
语法层(M1-1)在 `ggcore.plot` / `ggcore.registry` / `ggcore.aes` /
|
|
8
|
+
`ggcore.layer` / `ggcore.components`:`ggplot()` 对象、`+` 组合、克隆语义与
|
|
9
|
+
方法链别名。aes 表达式层(M1-2)在 `ggcore.eval`:字符串解析、白名单 AST
|
|
10
|
+
求值、数据掩码与自动分组(`docs/notes/aes.md`)。图层流水线(M1-3)在
|
|
11
|
+
`ggcore.build`:六阶段把 `ggplot` + `Layer` 变成每层已算好的数据
|
|
12
|
+
(`docs/notes/build.md`)。
|
|
13
|
+
|
|
14
|
+
IR(已解析几何的唯一中间表示)在 `ggcore.ir`,口径见 `docs/notes/ir.md`。
|
|
15
|
+
坐标底座在 `ggcore.units` / `ggcore.viewport`,口径见 `docs/notes/units.md` /
|
|
16
|
+
`docs/notes/viewport.md`。落盘(M1-12)在 `ggcore.io`:`ggsave()` 按后缀选设备、
|
|
17
|
+
`save_ir()` 写 `.ggir.cbor`、`export_ir_json()` 写调试视图,口径见
|
|
18
|
+
`docs/notes/io.md`。
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import ggcore.aes as aes
|
|
24
|
+
import ggcore.align as align
|
|
25
|
+
import ggcore.build as build
|
|
26
|
+
import ggcore.components as components
|
|
27
|
+
import ggcore.data as data
|
|
28
|
+
import ggcore.eval as eval
|
|
29
|
+
import ggcore.grobs as grobs
|
|
30
|
+
import ggcore.gtable as gtable
|
|
31
|
+
import ggcore.io as io
|
|
32
|
+
import ggcore.layer as layer
|
|
33
|
+
import ggcore.plot as plot
|
|
34
|
+
import ggcore.plotspec as plotspec
|
|
35
|
+
import ggcore.registry as registry
|
|
36
|
+
import ggcore.units as units
|
|
37
|
+
import ggcore.viewport as viewport
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"__version__",
|
|
41
|
+
"aes",
|
|
42
|
+
"align",
|
|
43
|
+
"build",
|
|
44
|
+
"components",
|
|
45
|
+
"data",
|
|
46
|
+
"eval",
|
|
47
|
+
"grobs",
|
|
48
|
+
"gtable",
|
|
49
|
+
"io",
|
|
50
|
+
"layer",
|
|
51
|
+
"plot",
|
|
52
|
+
"plotspec",
|
|
53
|
+
"registry",
|
|
54
|
+
"units",
|
|
55
|
+
"viewport",
|
|
56
|
+
]
|
|
57
|
+
__version__ = "0.1.0"
|