Skip to content

Commit 921dda3

Browse files
zorroozclaude
andcommitted
docs: 修正 README 管道顺序 + 新增 4 个 Phase 1 mark + 工厂函数
- 管道顺序修正: mark → scale → split → project → label → style → export - 分离 Theme & Export 为独立小节 - mark 表格新增 area/text/violin/map(10 个已实现) - 新增 Custom extensions 小节(make_mark/make_theme) - README_ZH 同步更新 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 630b397 commit 921dda3

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ compose_grid(p1, p2, tag_levels = "A") |>
7979
Every plotit chart follows a consistent pipeline:
8080

8181
```
82-
data |> plotit(encode(...)) |> mark_*() |> scale_*() |> label_*() |> project_*() |> split_*() |> style() |> export()
82+
data |> plotit(encode(...)) |> mark_*() |> scale_*() |> split_*() |> project_*() |> label_*() |> style() |> export()
8383
```
8484

8585
| Step | Verb | Role |
8686
|:---|:---|:---|
8787
| 1. Initialise | `plotit()` + `encode()` | Bind data and aesthetic mappings |
8888
| 2. Layer | `mark_*()` | Add geometric layers (points, lines, bars, …) |
8989
| 3. Scale | `scale_*()` | Control how data maps to visual properties |
90-
| 4. Label | `label_*()` | Set titles, axis labels, legend titles |
90+
| 4. Facet | `split_*()` | Split into small multiples |
9191
| 5. Coordinate | `project_*()` | Choose coordinate system (cartesian, polar, map) |
92-
| 6. Facet | `split_*()` | Split into small multiples |
92+
| 6. Label | `label_*()` | Set titles, axis labels, legend titles |
9393
| 7. Theme | `style()` | Apply a complete theme |
9494
| 8. Export | `export()` | Render to file |
9595

@@ -107,10 +107,14 @@ compose_*(p1, p2, ...) |> label_*() |> style() |> export()
107107
|:---|:---|:---|
108108
| `mark_point()` | `geom_point()` | Scatter plots |
109109
| `mark_line()` | `geom_line()` | Lines and trends |
110+
| `mark_area()` | `geom_area()` | Filled area / stream graph |
110111
| `mark_bar()` | `geom_bar()` / `geom_col()` | Bar charts |
112+
| `mark_text()` | `geom_text()` / `ggrepel` | Text labels and annotations |
111113
| `mark_boxplot()` | `geom_boxplot()` | Box-and-whisker plots |
112114
| `mark_histogram()` | `geom_histogram()` | Histograms |
113-
| `mark_density()` | `geom_density()` | Kernel density estimates |
115+
| `mark_density()` | `geom_density()` | 1D kernel density |
116+
| `mark_violin()` | `geom_violin()` | Violin plots |
117+
| `mark_map()` | `geom_sf()` | Geographic maps |
114118

115119
### `scale_*` — Data-to-visual mapping
116120

@@ -167,6 +171,13 @@ compose_*(p1, p2, ...) |> label_*() |> style() |> export()
167171
| `style_default()` | Restore plotit's built-in theme |
168172
| `export()` | Render to file (pdf, png, svg, …) |
169173

174+
### Custom extensions
175+
176+
| Function | Description |
177+
|:---|:---|
178+
| `make_mark()` | Register a custom mark from any ggplot2 geom |
179+
| `make_theme()` | Create a reusable theme preset function |
180+
170181
## Documentation
171182

172183
Full documentation is available at [zorrooz.github.io/plotit](https://zorrooz.github.io/plotit/).

README_ZH.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ compose_grid(p1, p2, tag_levels = "A") |>
7676
每个 plotit 图表都遵循一致的管道:
7777

7878
```
79-
data |> plotit(encode(...)) |> mark_*() |> scale_*() |> label_*() |> project_*() |> split_*() |> style() |> export()
79+
data |> plotit(encode(...)) |> mark_*() |> scale_*() |> split_*() |> project_*() |> label_*() |> style() |> export()
8080
```
8181

8282
| 步骤 | 动词 | 职责 |
8383
|:---|:---|:---|
8484
| 1. 初始化 | `plotit()` + `encode()` | 绑定数据与美学映射 |
8585
| 2. 图层 | `mark_*()` | 添加几何图层(点、线、柱等) |
8686
| 3. 标度 | `scale_*()` | 控制数据到视觉属性的映射 |
87-
| 4. 标签 | `label_*()` | 设置标题、轴标签、图例标题 |
87+
| 4. 分面 | `split_*()` | 拆分为小倍数图 |
8888
| 5. 坐标 | `project_*()` | 选择坐标系(笛卡尔、极坐标、地图) |
89-
| 6. 分面 | `split_*()` | 拆分为小倍数图 |
90-
| 7. 主题 | `style()` | 应用完整主题 |
89+
| 6. 标签 | `label_*()` | 设置标题、轴标签、图例标题 |
90+
| 7. 主题 | `style()` | 应用主题样式 |
9191
| 8. 导出 | `export()` | 渲染为文件 |
9292

9393
多图组合遵循最外层管道:
@@ -104,10 +104,14 @@ compose_*(p1, p2, ...) |> label_*() |> style() |> export()
104104
|:---|:---|:---|
105105
| `mark_point()` | `geom_point()` | 散点图 |
106106
| `mark_line()` | `geom_line()` | 折线与趋势线 |
107+
| `mark_area()` | `geom_area()` | 面积图/河流图 |
107108
| `mark_bar()` | `geom_bar()` / `geom_col()` | 柱状图 |
109+
| `mark_text()` | `geom_text()` / `ggrepel` | 文本标签与数据标注 |
108110
| `mark_boxplot()` | `geom_boxplot()` | 箱线图 |
109111
| `mark_histogram()` | `geom_histogram()` | 直方图 |
110-
| `mark_density()` | `geom_density()` | 核密度估计 |
112+
| `mark_density()` | `geom_density()` | 1D 核密度估计 |
113+
| `mark_violin()` | `geom_violin()` | 小提琴图 |
114+
| `mark_map()` | `geom_sf()` | 地图/地理空间 |
111115

112116
### `scale_*` — 数据到视觉的映射
113117

@@ -164,6 +168,13 @@ compose_*(p1, p2, ...) |> label_*() |> style() |> export()
164168
| `style_default()` | 恢复 plotit 内置主题 |
165169
| `export()` | 渲染为文件(pdf、png、svg 等) |
166170

171+
### 自定义扩展
172+
173+
| 函数 | 说明 |
174+
|:---|:---|
175+
| `make_mark()` | 基于任意 ggplot2 geom 注册自定义 Mark |
176+
| `make_theme()` | 创建可复用的主题预设函数 |
177+
167178
## 文档
168179

169180
完整文档见 [zorrooz.github.io/plotit](https://zorrooz.github.io/plotit/)

0 commit comments

Comments
 (0)