gog 0.0.1__py3-none-win_amd64.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.
- gog/__init__.py +172 -0
- gog/_bin/gog-cli.exe +0 -0
- gog/atoms.py +974 -0
- gog/columns.py +175 -0
- gog/errors.py +18 -0
- gog/render.py +361 -0
- gog/spec.py +728 -0
- gog-0.0.1.dist-info/METADATA +108 -0
- gog-0.0.1.dist-info/RECORD +12 -0
- gog-0.0.1.dist-info/WHEEL +4 -0
- gog-0.0.1.dist-info/licenses/LICENSE +202 -0
- gog-0.0.1.dist-info/licenses/NOTICE +58 -0
gog/__init__.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""gog — the Grammar of Graphics, spoken from Python.
|
|
2
|
+
|
|
3
|
+
A plot is a sentence: a table, a mark, and the channels that bind the mark to
|
|
4
|
+
the table's columns.
|
|
5
|
+
|
|
6
|
+
from gog import *
|
|
7
|
+
|
|
8
|
+
gapminder = {"gdp": [...], "life": [...], "continent": [...]}
|
|
9
|
+
p = data(gapminder) + point + x(col.gdp, scale="log") + y(col.life) + color(col.continent)
|
|
10
|
+
p.save("life.svg")
|
|
11
|
+
|
|
12
|
+
The same sentence in R is `data(gapminder) + point + x(gdp) + y(life) +
|
|
13
|
+
color(continent)`. One engine reads both: the binding builds a specification,
|
|
14
|
+
`gog-cli` draws it. Nothing about *what a plot means* lives in this package.
|
|
15
|
+
|
|
16
|
+
Two Python-specific things are worth knowing before the first plot.
|
|
17
|
+
|
|
18
|
+
**A column is `col.name`.** Python has no bare names, and in this grammar a
|
|
19
|
+
plain string is a *value* (`style(color="tomato")`, `title("...")`), so the
|
|
20
|
+
accessor is what keeps "which column?" and "which value?" apart — see
|
|
21
|
+
`gog/columns.py` for why the four characters earn their place.
|
|
22
|
+
|
|
23
|
+
**`from gog import *` shadows five builtins** — `bin`, `sum`, `min`, `max` and
|
|
24
|
+
`range` are transforms here. That is the same ruling the R package makes when
|
|
25
|
+
it masks `base::range` and `base::sum`: a DSL keeps its own vocabulary, and the
|
|
26
|
+
alternative is a grammar that reads `gog.bar * gog.bin + gog.x(...)`. Where a
|
|
27
|
+
module needs both, import the package instead (`import gog`) and spell the
|
|
28
|
+
sentence with the prefix, or re-import the builtin you need
|
|
29
|
+
(`from builtins import sum`).
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from .atoms import (
|
|
33
|
+
area,
|
|
34
|
+
bar,
|
|
35
|
+
bin,
|
|
36
|
+
bounds,
|
|
37
|
+
box,
|
|
38
|
+
color,
|
|
39
|
+
colour,
|
|
40
|
+
confidence,
|
|
41
|
+
count,
|
|
42
|
+
density,
|
|
43
|
+
dodge,
|
|
44
|
+
facet,
|
|
45
|
+
group,
|
|
46
|
+
interval,
|
|
47
|
+
jitter,
|
|
48
|
+
label,
|
|
49
|
+
line,
|
|
50
|
+
max,
|
|
51
|
+
mean,
|
|
52
|
+
median,
|
|
53
|
+
min,
|
|
54
|
+
nest,
|
|
55
|
+
opacity,
|
|
56
|
+
order,
|
|
57
|
+
palette,
|
|
58
|
+
partition,
|
|
59
|
+
path,
|
|
60
|
+
pattern,
|
|
61
|
+
play,
|
|
62
|
+
point,
|
|
63
|
+
polar,
|
|
64
|
+
proportion,
|
|
65
|
+
range,
|
|
66
|
+
ribbon,
|
|
67
|
+
rule,
|
|
68
|
+
shape,
|
|
69
|
+
size,
|
|
70
|
+
smooth,
|
|
71
|
+
space,
|
|
72
|
+
stack,
|
|
73
|
+
step,
|
|
74
|
+
style,
|
|
75
|
+
sum,
|
|
76
|
+
surface,
|
|
77
|
+
text,
|
|
78
|
+
theme,
|
|
79
|
+
title,
|
|
80
|
+
x,
|
|
81
|
+
x_label,
|
|
82
|
+
y,
|
|
83
|
+
y_label,
|
|
84
|
+
z,
|
|
85
|
+
z_label,
|
|
86
|
+
zone,
|
|
87
|
+
)
|
|
88
|
+
from .columns import col
|
|
89
|
+
from .errors import GogError
|
|
90
|
+
from .render import ordered, render_svg
|
|
91
|
+
from .spec import Page, Plot, data
|
|
92
|
+
|
|
93
|
+
# The seventh place a version is declared, and the one that hides: the other six
|
|
94
|
+
# are manifests a release process reads, this one is *code a user reads*. It sat
|
|
95
|
+
# at `0.0.0.dev0` while `pyproject.toml` said `0.0.1`, so every built wheel
|
|
96
|
+
# carried metadata and a `__version__` that disagreed — caught only because an
|
|
97
|
+
# upgrade in a venv reported the old number back. `test_basic.R`'s drift guard
|
|
98
|
+
# now covers this file too; it did not at first, because the guard enumerated
|
|
99
|
+
# manifests and this is source.
|
|
100
|
+
__version__ = "0.0.1"
|
|
101
|
+
|
|
102
|
+
__all__ = [
|
|
103
|
+
# the table
|
|
104
|
+
"data",
|
|
105
|
+
"col",
|
|
106
|
+
"ordered",
|
|
107
|
+
# marks
|
|
108
|
+
"point",
|
|
109
|
+
"line",
|
|
110
|
+
"path",
|
|
111
|
+
"rule",
|
|
112
|
+
"zone",
|
|
113
|
+
"area",
|
|
114
|
+
"bar",
|
|
115
|
+
"step",
|
|
116
|
+
"interval",
|
|
117
|
+
"box",
|
|
118
|
+
"ribbon",
|
|
119
|
+
"surface",
|
|
120
|
+
"text",
|
|
121
|
+
# transforms
|
|
122
|
+
"bin",
|
|
123
|
+
"smooth",
|
|
124
|
+
"count",
|
|
125
|
+
"density",
|
|
126
|
+
"sum",
|
|
127
|
+
"mean",
|
|
128
|
+
"median",
|
|
129
|
+
"max",
|
|
130
|
+
"min",
|
|
131
|
+
"proportion",
|
|
132
|
+
"range",
|
|
133
|
+
"confidence",
|
|
134
|
+
"bounds",
|
|
135
|
+
"partition",
|
|
136
|
+
"dodge",
|
|
137
|
+
"stack",
|
|
138
|
+
"jitter",
|
|
139
|
+
# positions and spaces
|
|
140
|
+
"x",
|
|
141
|
+
"y",
|
|
142
|
+
"z",
|
|
143
|
+
"space",
|
|
144
|
+
"polar",
|
|
145
|
+
"nest",
|
|
146
|
+
# channels
|
|
147
|
+
"color",
|
|
148
|
+
# exported only to be refused: the British spelling names its fix
|
|
149
|
+
"colour",
|
|
150
|
+
"group",
|
|
151
|
+
"size",
|
|
152
|
+
"shape",
|
|
153
|
+
"opacity",
|
|
154
|
+
"label",
|
|
155
|
+
"pattern",
|
|
156
|
+
"play",
|
|
157
|
+
# settings and plot-level atoms
|
|
158
|
+
"style",
|
|
159
|
+
"theme",
|
|
160
|
+
"order",
|
|
161
|
+
"facet",
|
|
162
|
+
"palette",
|
|
163
|
+
"title",
|
|
164
|
+
"x_label",
|
|
165
|
+
"y_label",
|
|
166
|
+
"z_label",
|
|
167
|
+
# rendering
|
|
168
|
+
"render_svg",
|
|
169
|
+
"Page",
|
|
170
|
+
"Plot",
|
|
171
|
+
"GogError",
|
|
172
|
+
]
|
gog/_bin/gog-cli.exe
ADDED
|
Binary file
|