plotcli-py 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.
- CLAUDE.md +51 -0
- LICENSE +21 -0
- PKG-INFO +358 -0
- README.md +340 -0
- main.py +6 -0
- plotcli-original/.Rbuildignore +18 -0
- plotcli-original/.github/workflows/deploy_docs.yml +43 -0
- plotcli-original/.gitignore +46 -0
- plotcli-original/DESCRIPTION +25 -0
- plotcli-original/NAMESPACE +60 -0
- plotcli-original/NEWS.md +112 -0
- plotcli-original/R/ascii_escape.r +13 -0
- plotcli-original/R/canvas.r +586 -0
- plotcli-original/R/class_functions.r +114 -0
- plotcli-original/R/geom_registry.r +1376 -0
- plotcli-original/R/ggplotcli.r +234 -0
- plotcli-original/R/ggplotcli_helpers.r +1099 -0
- plotcli-original/R/helper_functions.r +351 -0
- plotcli-original/R/plotcli.r +963 -0
- plotcli-original/R/plotcli_grid.r +1 -0
- plotcli-original/R/plotcli_wrappers.r +416 -0
- plotcli-original/R/zzz.r +15 -0
- plotcli-original/README.md +192 -0
- plotcli-original/docs/ascii.png +0 -0
- plotcli-original/docs/bar.png +0 -0
- plotcli-original/docs/block.png +0 -0
- plotcli-original/docs/boxplot.png +0 -0
- plotcli-original/docs/density.png +0 -0
- plotcli-original/docs/facet.png +0 -0
- plotcli-original/docs/facet_grid.png +0 -0
- plotcli-original/docs/generate_png.sh +137 -0
- plotcli-original/docs/heatmap.png +0 -0
- plotcli-original/docs/histogram.png +0 -0
- plotcli-original/docs/line.png +0 -0
- plotcli-original/docs/noborder.png +0 -0
- plotcli-original/docs/scatter.png +0 -0
- plotcli-original/docs/showcase.R +182 -0
- plotcli-original/inst/doc/ggplotcli.R +231 -0
- plotcli-original/inst/doc/ggplotcli.Rmd +329 -0
- plotcli-original/inst/doc/ggplotcli.html +1078 -0
- plotcli-original/inst/doc/plotcli_class.R +98 -0
- plotcli-original/inst/doc/plotcli_class.Rmd +121 -0
- plotcli-original/inst/doc/plotcli_class.html +564 -0
- plotcli-original/inst/doc/plotcli_wrappers.R +35 -0
- plotcli-original/inst/doc/plotcli_wrappers.Rmd +62 -0
- plotcli-original/inst/doc/plotcli_wrappers.html +546 -0
- plotcli-original/man/AsciiCanvas.Rd +116 -0
- plotcli-original/man/BlockCanvas.Rd +132 -0
- plotcli-original/man/BrailleCanvas.Rd +146 -0
- plotcli-original/man/Canvas.Rd +492 -0
- plotcli-original/man/GeomRegistry.Rd +9 -0
- plotcli-original/man/add_legend_to_output.Rd +12 -0
- plotcli-original/man/braille_dot_bit.Rd +29 -0
- plotcli-original/man/braille_set_dot.Rd +21 -0
- plotcli-original/man/bresenham.Rd +27 -0
- plotcli-original/man/build_plot_output.Rd +28 -0
- plotcli-original/man/build_plot_output_v2.Rd +41 -0
- plotcli-original/man/cat_plot_matrix.Rd +17 -0
- plotcli-original/man/cbind.plotcli.Rd +19 -0
- plotcli-original/man/cbind_plots.Rd +17 -0
- plotcli-original/man/color_to_term.Rd +18 -0
- plotcli-original/man/create_canvas.Rd +21 -0
- plotcli-original/man/create_panel_scales.Rd +29 -0
- plotcli-original/man/create_scales.Rd +27 -0
- plotcli-original/man/dot-geom_registry.Rd +16 -0
- plotcli-original/man/draw_border.Rd +12 -0
- plotcli-original/man/draw_grid.Rd +12 -0
- plotcli-original/man/extract_legend_info.Rd +12 -0
- plotcli-original/man/extract_plot_labels.Rd +12 -0
- plotcli-original/man/extract_plot_style.Rd +12 -0
- plotcli-original/man/format_axis_label.Rd +18 -0
- plotcli-original/man/format_four_chars.Rd +21 -0
- plotcli-original/man/geom_area_handler.Rd +12 -0
- plotcli-original/man/geom_bar_handler.Rd +12 -0
- plotcli-original/man/geom_boxplot_handler.Rd +13 -0
- plotcli-original/man/geom_density_handler.Rd +12 -0
- plotcli-original/man/geom_histogram_handler.Rd +12 -0
- plotcli-original/man/geom_hline_handler.Rd +12 -0
- plotcli-original/man/geom_line_handler.Rd +12 -0
- plotcli-original/man/geom_path_handler.Rd +12 -0
- plotcli-original/man/geom_point_handler.Rd +12 -0
- plotcli-original/man/geom_rect_handler.Rd +12 -0
- plotcli-original/man/geom_segment_handler.Rd +12 -0
- plotcli-original/man/geom_smooth_handler.Rd +12 -0
- plotcli-original/man/geom_text_handler.Rd +12 -0
- plotcli-original/man/geom_vline_handler.Rd +12 -0
- plotcli-original/man/get_color_hue.Rd +18 -0
- plotcli-original/man/get_data_subset.Rd +23 -0
- plotcli-original/man/get_facet_info.Rd +18 -0
- plotcli-original/man/get_geom_handler.Rd +17 -0
- plotcli-original/man/get_term_colors.Rd +21 -0
- plotcli-original/man/ggplotcli.Rd +83 -0
- plotcli-original/man/init_color_mapping.Rd +15 -0
- plotcli-original/man/is_braille.Rd +20 -0
- plotcli-original/man/is_geom_registered.Rd +17 -0
- plotcli-original/man/list_registered_geoms.Rd +14 -0
- plotcli-original/man/make_colored.Rd +23 -0
- plotcli-original/man/make_unique_names.Rd +20 -0
- plotcli-original/man/normalize_data.Rd +27 -0
- plotcli-original/man/pclib.Rd +48 -0
- plotcli-original/man/pclibx.Rd +46 -0
- plotcli-original/man/pclid.Rd +44 -0
- plotcli-original/man/pclih.Rd +50 -0
- plotcli-original/man/pclil.Rd +48 -0
- plotcli-original/man/pclis.Rd +48 -0
- plotcli-original/man/pixel_to_braille.Rd +23 -0
- plotcli-original/man/plotcli.Rd +598 -0
- plotcli-original/man/plotcli_bar.Rd +48 -0
- plotcli-original/man/plotcli_box.Rd +46 -0
- plotcli-original/man/plotcli_density.Rd +44 -0
- plotcli-original/man/plotcli_histogram.Rd +50 -0
- plotcli-original/man/plotcli_line.Rd +48 -0
- plotcli-original/man/plotcli_options.Rd +18 -0
- plotcli-original/man/plotcli_scatter.Rd +48 -0
- plotcli-original/man/plus-.plotcli.Rd +19 -0
- plotcli-original/man/rbind.plotcli.Rd +19 -0
- plotcli-original/man/rbind_plots.Rd +17 -0
- plotcli-original/man/register_geom.Rd +21 -0
- plotcli-original/man/remove_color_codes.Rd +21 -0
- plotcli-original/man/render_faceted_plot.Rd +25 -0
- plotcli-original/man/render_single_panel.Rd +12 -0
- plotcli-original/man/safe_aes_name.Rd +18 -0
- plotcli-original/tests/testthat/test-new-geoms.R +136 -0
- plotcli-original/tests/testthat/test-plotcli.R +69 -0
- plotcli-original/tests/testthat.R +4 -0
- plotcli-original/vignettes/ggplotcli.Rmd +329 -0
- plotcli-original/vignettes/plotcli_class.R +98 -0
- plotcli-original/vignettes/plotcli_class.Rmd +121 -0
- plotcli-original/vignettes/plotcli_wrappers.R +35 -0
- plotcli-original/vignettes/plotcli_wrappers.Rmd +62 -0
- plotcli.egg-info/PKG-INFO +11 -0
- plotcli.egg-info/SOURCES.txt +7 -0
- plotcli.egg-info/dependency_links.txt +1 -0
- plotcli.egg-info/entry_points.txt +3 -0
- plotcli.egg-info/top_level.txt +1 -0
- plotcli.py +978 -0
- plotcli_py-0.1.0.dist-info/METADATA +358 -0
- plotcli_py-0.1.0.dist-info/RECORD +143 -0
- plotcli_py-0.1.0.dist-info/WHEEL +4 -0
- plotcli_py-0.1.0.dist-info/entry_points.txt +2 -0
- plotcli_py-0.1.0.dist-info/licenses/LICENSE +21 -0
- pyproject.toml +31 -0
- uv.lock +8 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ggplotcli: Universal ggplot2 to Terminal Plotting"
|
|
3
|
+
author: "Claas Heuer"
|
|
4
|
+
date: "`r Sys.Date()`"
|
|
5
|
+
output: rmarkdown::html_vignette
|
|
6
|
+
vignette: >
|
|
7
|
+
%\VignetteIndexEntry{ggplotcli: Universal ggplot2 to Terminal Plotting}
|
|
8
|
+
%\VignetteEngine{knitr::rmarkdown}
|
|
9
|
+
%\VignetteEncoding{UTF-8}
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```{r setup, include = FALSE}
|
|
13
|
+
knitr::opts_chunk$set(
|
|
14
|
+
collapse = TRUE,
|
|
15
|
+
comment = "#>"
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Introduction
|
|
20
|
+
|
|
21
|
+
`ggplotcli` is a universal converter that renders any ggplot2 plot in the terminal using Unicode/ASCII characters. It automatically extracts data, aesthetics, and styling from ggplot objects, supporting 15+ geom types, faceting, color aesthetics, and legends.
|
|
22
|
+
|
|
23
|
+
## Basic Usage
|
|
24
|
+
|
|
25
|
+
```{r}
|
|
26
|
+
library(plotcli)
|
|
27
|
+
library(ggplot2)
|
|
28
|
+
|
|
29
|
+
# Create a ggplot
|
|
30
|
+
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) +
|
|
31
|
+
geom_point() +
|
|
32
|
+
labs(title = "MPG vs Weight by Cylinders")
|
|
33
|
+
|
|
34
|
+
# Render in terminal
|
|
35
|
+
ggplotcli(p, width = 60, height = 16)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Supported Geoms
|
|
39
|
+
|
|
40
|
+
### Scatter Plots (geom_point)
|
|
41
|
+
|
|
42
|
+
```{r}
|
|
43
|
+
p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
|
|
44
|
+
geom_point() +
|
|
45
|
+
labs(title = "Iris: Sepal Dimensions by Species")
|
|
46
|
+
ggplotcli(p, width = 60, height = 16)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Line Plots (geom_line)
|
|
50
|
+
|
|
51
|
+
```{r}
|
|
52
|
+
# Multiple colored lines
|
|
53
|
+
df <- data.frame(
|
|
54
|
+
x = rep(1:30, 2),
|
|
55
|
+
y = c(sin(1:30/4) * 10, cos(1:30/4) * 10),
|
|
56
|
+
type = rep(c("sin", "cos"), each = 30)
|
|
57
|
+
)
|
|
58
|
+
p <- ggplot(df, aes(x, y, color = type)) +
|
|
59
|
+
geom_line() +
|
|
60
|
+
labs(title = "Sine and Cosine Waves")
|
|
61
|
+
ggplotcli(p, width = 60, height = 12)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Histograms (geom_histogram)
|
|
65
|
+
|
|
66
|
+
```{r}
|
|
67
|
+
p <- ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) +
|
|
68
|
+
geom_histogram(bins = 10, position = "dodge") +
|
|
69
|
+
labs(title = "MPG Distribution by Cylinders")
|
|
70
|
+
ggplotcli(p, width = 60, height = 12)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Density Plots (geom_density)
|
|
74
|
+
|
|
75
|
+
```{r}
|
|
76
|
+
p <- ggplot(mtcars, aes(x = mpg, color = factor(cyl))) +
|
|
77
|
+
geom_density() +
|
|
78
|
+
labs(title = "MPG Density by Cylinders")
|
|
79
|
+
ggplotcli(p, width = 60, height = 12)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Bar Charts (geom_col)
|
|
83
|
+
|
|
84
|
+
```{r}
|
|
85
|
+
df <- data.frame(
|
|
86
|
+
category = c("A", "B", "C", "D", "E", "F"),
|
|
87
|
+
value = c(25, 45, 30, 60, 35, 50)
|
|
88
|
+
)
|
|
89
|
+
p <- ggplot(df, aes(x = category, y = value, fill = category)) +
|
|
90
|
+
geom_col() +
|
|
91
|
+
labs(title = "Category Values")
|
|
92
|
+
ggplotcli(p, width = 60, height = 12)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Boxplots (geom_boxplot)
|
|
96
|
+
|
|
97
|
+
Boxplots are rendered with box-drawing characters by default, showing whiskers, box (Q1-Q3), median line, and outliers:
|
|
98
|
+
|
|
99
|
+
```{r}
|
|
100
|
+
set.seed(42)
|
|
101
|
+
df <- data.frame(
|
|
102
|
+
group = factor(rep(paste0("Group ", 1:6), each = 50)),
|
|
103
|
+
value = c(rnorm(50, 10, 3), rnorm(50, 5, 2), rnorm(50, 8, 4),
|
|
104
|
+
rnorm(50, 6, 2), rnorm(50, 12, 3), rnorm(50, 7, 2))
|
|
105
|
+
)
|
|
106
|
+
p <- ggplot(df, aes(x = group, y = value, fill = group)) +
|
|
107
|
+
geom_boxplot() +
|
|
108
|
+
labs(title = "Boxplot Colored by Group", y = "Value", x = "Group")
|
|
109
|
+
ggplotcli(p, width = 80, height = 20, boxplot_style = "ascii")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
You can also use Braille rendering for boxplots:
|
|
113
|
+
|
|
114
|
+
```{r}
|
|
115
|
+
ggplotcli(p, width = 80, height = 20, boxplot_style = "braille")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Combining Multiple Geoms
|
|
119
|
+
|
|
120
|
+
```{r}
|
|
121
|
+
# Histogram with density overlay
|
|
122
|
+
p <- ggplot(mtcars, aes(x = mpg)) +
|
|
123
|
+
geom_histogram(aes(y = after_stat(density)), bins = 10, fill = "gray") +
|
|
124
|
+
geom_density(color = "red") +
|
|
125
|
+
labs(title = "Histogram with Density Overlay")
|
|
126
|
+
ggplotcli(p, width = 60, height = 12)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```{r}
|
|
130
|
+
# Points with smooth line
|
|
131
|
+
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
|
|
132
|
+
geom_point(color = "gray") +
|
|
133
|
+
geom_smooth(method = "loess", color = "red") +
|
|
134
|
+
labs(title = "Scatter with LOESS Smooth")
|
|
135
|
+
suppressMessages(ggplotcli(p, width = 60, height = 12))
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Faceting
|
|
139
|
+
|
|
140
|
+
### facet_wrap with Color Aesthetics
|
|
141
|
+
|
|
142
|
+
Faceting works seamlessly with color/fill aesthetics and legends:
|
|
143
|
+
|
|
144
|
+
```{r}
|
|
145
|
+
mtcars$cyl_fac <- factor(mtcars$cyl)
|
|
146
|
+
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = cyl_fac)) +
|
|
147
|
+
geom_point() +
|
|
148
|
+
facet_wrap(~cyl_fac) +
|
|
149
|
+
labs(title = "MPG vs Weight: Faceted by Cylinders")
|
|
150
|
+
ggplotcli(p, width = 75, height = 16)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### facet_grid
|
|
154
|
+
|
|
155
|
+
```{r}
|
|
156
|
+
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(gear))) +
|
|
157
|
+
geom_point() +
|
|
158
|
+
facet_grid(am ~ cyl) +
|
|
159
|
+
labs(title = "MPG: AM (rows) x Cylinders (cols)")
|
|
160
|
+
ggplotcli(p, width = 80, height = 20)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Styling Options
|
|
164
|
+
|
|
165
|
+
### Borders and Grid Lines
|
|
166
|
+
|
|
167
|
+
```{r}
|
|
168
|
+
p <- ggplot(mtcars, aes(x = hp, y = qsec)) +
|
|
169
|
+
geom_point(color = "cyan") +
|
|
170
|
+
labs(title = "Quarter Mile Time vs HP")
|
|
171
|
+
|
|
172
|
+
# With border
|
|
173
|
+
ggplotcli(p, width = 55, height = 12, border = TRUE)
|
|
174
|
+
|
|
175
|
+
# With grid
|
|
176
|
+
ggplotcli(p, width = 55, height = 12, grid = "major")
|
|
177
|
+
|
|
178
|
+
# Both
|
|
179
|
+
ggplotcli(p, width = 55, height = 12, border = TRUE, grid = "major")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Theme Auto-Detection
|
|
183
|
+
|
|
184
|
+
ggplotcli automatically respects ggplot2 themes:
|
|
185
|
+
|
|
186
|
+
```{r}
|
|
187
|
+
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
|
|
188
|
+
geom_point(color = "blue") +
|
|
189
|
+
labs(title = "theme_bw() - Grid + Border")
|
|
190
|
+
|
|
191
|
+
# theme_bw has both grid and border
|
|
192
|
+
ggplotcli(p + theme_bw(), width = 60, height = 14, border = "auto", grid = "auto")
|
|
193
|
+
|
|
194
|
+
# theme_classic has border but no grid
|
|
195
|
+
ggplotcli(p + theme_classic() + labs(title = "theme_classic() - Border Only"),
|
|
196
|
+
width = 60, height = 14, border = "auto", grid = "auto")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Canvas Types
|
|
200
|
+
|
|
201
|
+
Three rendering modes are available:
|
|
202
|
+
|
|
203
|
+
```{r}
|
|
204
|
+
wave <- ggplot(data.frame(x = 1:25, y = sin(1:25/4)*8), aes(x, y)) +
|
|
205
|
+
geom_line(color = "green")
|
|
206
|
+
|
|
207
|
+
# Braille (highest resolution - 2x4 dots per character)
|
|
208
|
+
ggplotcli(wave + labs(title = "Braille Canvas (highest resolution)"),
|
|
209
|
+
width = 50, height = 8, canvas_type = "braille")
|
|
210
|
+
|
|
211
|
+
# Block (medium resolution - uses block characters)
|
|
212
|
+
ggplotcli(wave + labs(title = "Block Canvas (medium resolution)"),
|
|
213
|
+
width = 50, height = 8, canvas_type = "block")
|
|
214
|
+
|
|
215
|
+
# ASCII (basic, most compatible)
|
|
216
|
+
ggplotcli(wave + labs(title = "ASCII Canvas (most compatible)"),
|
|
217
|
+
width = 50, height = 8, canvas_type = "ascii")
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Color Mapping
|
|
221
|
+
|
|
222
|
+
ggplotcli intelligently maps ggplot2 colors to terminal colors (red, yellow, green, cyan, blue, magenta). The mapping prioritizes **color distinctness** over hue accuracy to maximize visual differentiation between groups.
|
|
223
|
+
|
|
224
|
+
### Many Groups (8+)
|
|
225
|
+
|
|
226
|
+
Even with many groups, colors are distributed to minimize repetition:
|
|
227
|
+
|
|
228
|
+
```{r}
|
|
229
|
+
set.seed(123)
|
|
230
|
+
df <- data.frame(
|
|
231
|
+
group = factor(rep(paste0("G", 1:8), each = 30)),
|
|
232
|
+
value = unlist(lapply(1:8, function(i) rnorm(30, mean = i * 2, sd = 1.5)))
|
|
233
|
+
)
|
|
234
|
+
p <- ggplot(df, aes(x = group, y = value, fill = group)) +
|
|
235
|
+
geom_boxplot() +
|
|
236
|
+
labs(title = "8 Groups with Optimized Color Distribution")
|
|
237
|
+
ggplotcli(p, width = 85, height = 18, boxplot_style = "ascii")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Showcase: Maximum Complexity
|
|
241
|
+
|
|
242
|
+
### Complex Faceted Boxplot
|
|
243
|
+
|
|
244
|
+
```{r}
|
|
245
|
+
set.seed(42)
|
|
246
|
+
df <- data.frame(
|
|
247
|
+
treatment = factor(rep(c("Control", "Drug A", "Drug B"), each = 60)),
|
|
248
|
+
timepoint = factor(rep(rep(c("Baseline", "Week 4", "Week 8"), each = 20), 3)),
|
|
249
|
+
response = c(
|
|
250
|
+
rnorm(20, 50, 10), rnorm(20, 52, 10), rnorm(20, 51, 10), # Control
|
|
251
|
+
rnorm(20, 50, 10), rnorm(20, 65, 12), rnorm(20, 70, 11), # Drug A
|
|
252
|
+
rnorm(20, 50, 10), rnorm(20, 58, 11), rnorm(20, 62, 10) # Drug B
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
p <- ggplot(df, aes(x = timepoint, y = response)) +
|
|
257
|
+
geom_boxplot(aes(fill = treatment)) +
|
|
258
|
+
labs(title = "Treatment Response Over Time",
|
|
259
|
+
subtitle = "Faceted by treatment group",
|
|
260
|
+
x = "Timepoint", y = "Response") +
|
|
261
|
+
theme_bw()
|
|
262
|
+
|
|
263
|
+
ggplotcli(p, width = 100, height = 22, boxplot_style = "ascii")
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Multi-Layer Scientific Plot
|
|
267
|
+
|
|
268
|
+
```{r}
|
|
269
|
+
# Simulated experiment data
|
|
270
|
+
set.seed(123)
|
|
271
|
+
x <- seq(0, 10, length.out = 50)
|
|
272
|
+
df <- data.frame(
|
|
273
|
+
x = rep(x, 3),
|
|
274
|
+
y = c(
|
|
275
|
+
2 * x + rnorm(50, 0, 1.5),
|
|
276
|
+
1.5 * x + 3 + rnorm(50, 0, 1.2),
|
|
277
|
+
x^1.2 + rnorm(50, 0, 1)
|
|
278
|
+
),
|
|
279
|
+
group = rep(c("Linear", "Offset", "Power"), each = 50)
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
p <- ggplot(df, aes(x = x, y = y, color = group)) +
|
|
283
|
+
geom_point(alpha = 0.6) +
|
|
284
|
+
geom_smooth(method = "loess", se = FALSE) +
|
|
285
|
+
labs(title = "Multi-Group Regression Analysis",
|
|
286
|
+
subtitle = "Points with LOESS smoothing",
|
|
287
|
+
x = "Predictor", y = "Response") +
|
|
288
|
+
theme_minimal()
|
|
289
|
+
|
|
290
|
+
suppressMessages(ggplotcli(p, width = 70, height = 18))
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Dense Scatter with Facets
|
|
294
|
+
|
|
295
|
+
```{r}
|
|
296
|
+
p <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) +
|
|
297
|
+
geom_point() +
|
|
298
|
+
facet_wrap(~Species) +
|
|
299
|
+
labs(title = "Iris Dataset: Sepal vs Petal Length",
|
|
300
|
+
subtitle = "Faceted by species with color legend") +
|
|
301
|
+
theme_bw()
|
|
302
|
+
|
|
303
|
+
ggplotcli(p, width = 80, height = 16)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Supported Features Summary
|
|
307
|
+
|
|
308
|
+
| Feature | Status |
|
|
309
|
+
|---------|--------|
|
|
310
|
+
| geom_point | ✓ |
|
|
311
|
+
| geom_line, geom_path | ✓ |
|
|
312
|
+
| geom_bar, geom_col, geom_histogram | ✓ |
|
|
313
|
+
| geom_density | ✓ |
|
|
314
|
+
| geom_smooth | ✓ |
|
|
315
|
+
| geom_area | ✓ |
|
|
316
|
+
| geom_segment, geom_hline, geom_vline | ✓ |
|
|
317
|
+
| geom_rect | ✓ |
|
|
318
|
+
| geom_text | ✓ |
|
|
319
|
+
| geom_boxplot | ✓ |
|
|
320
|
+
| Color/fill aesthetics | ✓ |
|
|
321
|
+
| Legends (auto-generated) | ✓ |
|
|
322
|
+
| facet_wrap, facet_grid | ✓ |
|
|
323
|
+
| Titles, subtitles, captions | ✓ |
|
|
324
|
+
| Theme auto-detection | ✓ |
|
|
325
|
+
| Optimized color mapping | ✓ |
|
|
326
|
+
| Multiple canvas types | ✓ |
|
|
327
|
+
| geom_tile (heatmaps) | Planned |
|
|
328
|
+
| geom_violin | Planned |
|
|
329
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
## ----setup, include = FALSE---------------------------------------------------
|
|
2
|
+
knitr::opts_chunk$set(
|
|
3
|
+
collapse = TRUE,
|
|
4
|
+
comment = "#>"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
## -----------------------------------------------------------------------------
|
|
8
|
+
library(plotcli)
|
|
9
|
+
|
|
10
|
+
plot_width = 80
|
|
11
|
+
plot_height = 40
|
|
12
|
+
|
|
13
|
+
# Create some example data
|
|
14
|
+
x <- seq(0, 2 * pi, length.out = 100)
|
|
15
|
+
y1 <- sin(x)
|
|
16
|
+
y2 <- cos(x)
|
|
17
|
+
|
|
18
|
+
data_1 = list(
|
|
19
|
+
x = x,
|
|
20
|
+
y = y1,
|
|
21
|
+
name = "y1 = sin(x)",
|
|
22
|
+
color = "blue",
|
|
23
|
+
type = "line",
|
|
24
|
+
braille = FALSE
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
data_2 = list(
|
|
28
|
+
x = x,
|
|
29
|
+
y = y2,
|
|
30
|
+
name = "y2 = cos(x)",
|
|
31
|
+
color = "red",
|
|
32
|
+
type = "line",
|
|
33
|
+
braille = FALSE
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Create a plotcli object with specified dimensions
|
|
37
|
+
plot <- plotcli$new(
|
|
38
|
+
plot_width = plot_width,
|
|
39
|
+
plot_height = plot_height,
|
|
40
|
+
x_label = "X-axis",
|
|
41
|
+
y_label = "Y-axis"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Add data sets to the plot
|
|
45
|
+
plot$add_data(data_1)
|
|
46
|
+
plot$add_data(data_2)
|
|
47
|
+
|
|
48
|
+
# Print the plot
|
|
49
|
+
plot$print_plot()
|
|
50
|
+
|
|
51
|
+
## -----------------------------------------------------------------------------
|
|
52
|
+
library(plotcli)
|
|
53
|
+
|
|
54
|
+
data(mtcars)
|
|
55
|
+
|
|
56
|
+
# Fit a linear model
|
|
57
|
+
lm_fit <- lm(wt ~ mpg, data = mtcars)
|
|
58
|
+
|
|
59
|
+
# Create a new dataset with the predicted values
|
|
60
|
+
predicted_data <- data.frame(mpg = mtcars$mpg, predicted_wt = predict(lm_fit, mtcars))
|
|
61
|
+
|
|
62
|
+
# we use braille characters for the regression line
|
|
63
|
+
data_1 = list(
|
|
64
|
+
x = predicted_data$mpg,
|
|
65
|
+
y = predicted_data$predicted_wt,
|
|
66
|
+
name = "Regression Line",
|
|
67
|
+
color = "red",
|
|
68
|
+
type = "line",
|
|
69
|
+
braille = TRUE
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# and ascii characters for the raw data
|
|
73
|
+
data_2 = list(
|
|
74
|
+
x = mtcars$mpg,
|
|
75
|
+
y = mtcars$wt,
|
|
76
|
+
name = "Data Points",
|
|
77
|
+
color = "blue",
|
|
78
|
+
type = "scatter",
|
|
79
|
+
braille = FALSE
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Create a plotcli object
|
|
83
|
+
plot_width = 80
|
|
84
|
+
plot_height = 40
|
|
85
|
+
plot_obj <- plotcli$new(
|
|
86
|
+
plot_width,
|
|
87
|
+
plot_height,
|
|
88
|
+
x_label = "Miles per Gallon",
|
|
89
|
+
y_label = "Weight"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Add raw data and regression line
|
|
93
|
+
plot_obj$add_data(data_1)
|
|
94
|
+
plot_obj$add_data(data_2)
|
|
95
|
+
|
|
96
|
+
# Print the plot
|
|
97
|
+
plot_obj$print_plot()
|
|
98
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Using the plotcli R6 Class"
|
|
3
|
+
author: "Claas Heuer"
|
|
4
|
+
date: "`r Sys.Date()`"
|
|
5
|
+
output: rmarkdown::html_vignette
|
|
6
|
+
vignette: >
|
|
7
|
+
%\VignetteIndexEntry{Using the plotcli R6 Class}
|
|
8
|
+
%\VignetteEngine{knitr::rmarkdown}
|
|
9
|
+
%\VignetteEncoding{UTF-8}
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```{r setup, include = FALSE}
|
|
13
|
+
knitr::opts_chunk$set(
|
|
14
|
+
collapse = TRUE,
|
|
15
|
+
comment = "#>"
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Using plotcli R6 class
|
|
20
|
+
|
|
21
|
+
# Setting up a scatter plot with two data sets
|
|
22
|
+
|
|
23
|
+
```{r}
|
|
24
|
+
library(plotcli)
|
|
25
|
+
|
|
26
|
+
plot_width = 80
|
|
27
|
+
plot_height = 40
|
|
28
|
+
|
|
29
|
+
# Create some example data
|
|
30
|
+
x <- seq(0, 2 * pi, length.out = 100)
|
|
31
|
+
y1 <- sin(x)
|
|
32
|
+
y2 <- cos(x)
|
|
33
|
+
|
|
34
|
+
data_1 = list(
|
|
35
|
+
x = x,
|
|
36
|
+
y = y1,
|
|
37
|
+
name = "y1 = sin(x)",
|
|
38
|
+
color = "blue",
|
|
39
|
+
type = "line",
|
|
40
|
+
braille = FALSE
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
data_2 = list(
|
|
44
|
+
x = x,
|
|
45
|
+
y = y2,
|
|
46
|
+
name = "y2 = cos(x)",
|
|
47
|
+
color = "red",
|
|
48
|
+
type = "line",
|
|
49
|
+
braille = FALSE
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Create a plotcli object with specified dimensions
|
|
53
|
+
plot <- plotcli$new(
|
|
54
|
+
plot_width = plot_width,
|
|
55
|
+
plot_height = plot_height,
|
|
56
|
+
x_label = "X-axis",
|
|
57
|
+
y_label = "Y-axis"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Add data sets to the plot
|
|
61
|
+
plot$add_data(data_1)
|
|
62
|
+
plot$add_data(data_2)
|
|
63
|
+
|
|
64
|
+
# Print the plot
|
|
65
|
+
plot$print_plot()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
# Combining Ascii and braille characters
|
|
69
|
+
|
|
70
|
+
plotcli can use braille characters for plotting scatter
|
|
71
|
+
and line plots, which give a much higher resolution on supported terminals.
|
|
72
|
+
Whether to use braille or ascii characters can be specified for each data set.
|
|
73
|
+
|
|
74
|
+
```{r}
|
|
75
|
+
library(plotcli)
|
|
76
|
+
|
|
77
|
+
data(mtcars)
|
|
78
|
+
|
|
79
|
+
# Fit a linear model
|
|
80
|
+
lm_fit <- lm(wt ~ mpg, data = mtcars)
|
|
81
|
+
|
|
82
|
+
# Create a new dataset with the predicted values
|
|
83
|
+
predicted_data <- data.frame(mpg = mtcars$mpg, predicted_wt = predict(lm_fit, mtcars))
|
|
84
|
+
|
|
85
|
+
# we use braille characters for the regression line
|
|
86
|
+
data_1 = list(
|
|
87
|
+
x = predicted_data$mpg,
|
|
88
|
+
y = predicted_data$predicted_wt,
|
|
89
|
+
name = "Regression Line",
|
|
90
|
+
color = "red",
|
|
91
|
+
type = "line",
|
|
92
|
+
braille = TRUE
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# and ascii characters for the raw data
|
|
96
|
+
data_2 = list(
|
|
97
|
+
x = mtcars$mpg,
|
|
98
|
+
y = mtcars$wt,
|
|
99
|
+
name = "Data Points",
|
|
100
|
+
color = "blue",
|
|
101
|
+
type = "scatter",
|
|
102
|
+
braille = FALSE
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Create a plotcli object
|
|
106
|
+
plot_width = 80
|
|
107
|
+
plot_height = 40
|
|
108
|
+
plot_obj <- plotcli$new(
|
|
109
|
+
plot_width,
|
|
110
|
+
plot_height,
|
|
111
|
+
x_label = "Miles per Gallon",
|
|
112
|
+
y_label = "Weight"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Add raw data and regression line
|
|
116
|
+
plot_obj$add_data(data_1)
|
|
117
|
+
plot_obj$add_data(data_2)
|
|
118
|
+
|
|
119
|
+
# Print the plot
|
|
120
|
+
plot_obj$print_plot()
|
|
121
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
## ----setup, include = FALSE---------------------------------------------------
|
|
2
|
+
knitr::opts_chunk$set(
|
|
3
|
+
collapse = TRUE,
|
|
4
|
+
comment = "#>"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
## -----------------------------------------------------------------------------
|
|
8
|
+
library(plotcli)
|
|
9
|
+
# Generate sample data
|
|
10
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
11
|
+
|
|
12
|
+
# Create a density plot
|
|
13
|
+
plotcli_density(sample_data, color = "blue", braille = TRUE)
|
|
14
|
+
|
|
15
|
+
## -----------------------------------------------------------------------------
|
|
16
|
+
# Generate sample data
|
|
17
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
18
|
+
|
|
19
|
+
# Create a histogram
|
|
20
|
+
plotcli_histogram(sample_data, color = "yellow")
|
|
21
|
+
|
|
22
|
+
## -----------------------------------------------------------------------------
|
|
23
|
+
# Create a scatter plot
|
|
24
|
+
plotcli_scatter(x = iris$`Sepal.Width`, y = iris$`Sepal.Length`, color = "magenta", braille = FALSE)
|
|
25
|
+
|
|
26
|
+
## -----------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
# make sin
|
|
29
|
+
x <- seq(0, 2*pi, length.out = 50)
|
|
30
|
+
y <- sin(x)
|
|
31
|
+
|
|
32
|
+
# Create a line plot
|
|
33
|
+
plotcli_line(x = x, y = cos(y), color = "green")
|
|
34
|
+
plotcli_line(x = x, y = x, color = "magenta", braille = FALSE)
|
|
35
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "plotcli Convenience Wrappers"
|
|
3
|
+
author: "Claas Heuer"
|
|
4
|
+
date: "`r Sys.Date()`"
|
|
5
|
+
output: rmarkdown::html_vignette
|
|
6
|
+
vignette: >
|
|
7
|
+
%\VignetteIndexEntry{plotcli Convenience Wrappers}
|
|
8
|
+
%\VignetteEngine{knitr::rmarkdown}
|
|
9
|
+
%\VignetteEncoding{UTF-8}
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
```{r setup, include = FALSE}
|
|
13
|
+
knitr::opts_chunk$set(
|
|
14
|
+
collapse = TRUE,
|
|
15
|
+
comment = "#>"
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Using `plotcli` convenience wrappers
|
|
20
|
+
|
|
21
|
+
# Density plot
|
|
22
|
+
|
|
23
|
+
```{r}
|
|
24
|
+
library(plotcli)
|
|
25
|
+
# Generate sample data
|
|
26
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
27
|
+
|
|
28
|
+
# Create a density plot
|
|
29
|
+
plotcli_density(sample_data, color = "blue", braille = TRUE)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
# Histogram
|
|
33
|
+
|
|
34
|
+
```{r}
|
|
35
|
+
# Generate sample data
|
|
36
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
37
|
+
|
|
38
|
+
# Create a histogram
|
|
39
|
+
plotcli_histogram(sample_data, color = "yellow")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
# Scatterplot
|
|
43
|
+
|
|
44
|
+
```{r}
|
|
45
|
+
# Create a scatter plot
|
|
46
|
+
plotcli_scatter(x = iris$`Sepal.Width`, y = iris$`Sepal.Length`, color = "magenta", braille = FALSE)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
# Lineplot
|
|
50
|
+
|
|
51
|
+
```{r}
|
|
52
|
+
|
|
53
|
+
# make sin
|
|
54
|
+
x <- seq(0, 2*pi, length.out = 50)
|
|
55
|
+
y <- sin(x)
|
|
56
|
+
|
|
57
|
+
# Create a line plot
|
|
58
|
+
plotcli_line(x = x, y = cos(y), color = "green")
|
|
59
|
+
plotcli_line(x = x, y = x, color = "magenta", braille = FALSE)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
plotcli
|