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.
Files changed (143) hide show
  1. CLAUDE.md +51 -0
  2. LICENSE +21 -0
  3. PKG-INFO +358 -0
  4. README.md +340 -0
  5. main.py +6 -0
  6. plotcli-original/.Rbuildignore +18 -0
  7. plotcli-original/.github/workflows/deploy_docs.yml +43 -0
  8. plotcli-original/.gitignore +46 -0
  9. plotcli-original/DESCRIPTION +25 -0
  10. plotcli-original/NAMESPACE +60 -0
  11. plotcli-original/NEWS.md +112 -0
  12. plotcli-original/R/ascii_escape.r +13 -0
  13. plotcli-original/R/canvas.r +586 -0
  14. plotcli-original/R/class_functions.r +114 -0
  15. plotcli-original/R/geom_registry.r +1376 -0
  16. plotcli-original/R/ggplotcli.r +234 -0
  17. plotcli-original/R/ggplotcli_helpers.r +1099 -0
  18. plotcli-original/R/helper_functions.r +351 -0
  19. plotcli-original/R/plotcli.r +963 -0
  20. plotcli-original/R/plotcli_grid.r +1 -0
  21. plotcli-original/R/plotcli_wrappers.r +416 -0
  22. plotcli-original/R/zzz.r +15 -0
  23. plotcli-original/README.md +192 -0
  24. plotcli-original/docs/ascii.png +0 -0
  25. plotcli-original/docs/bar.png +0 -0
  26. plotcli-original/docs/block.png +0 -0
  27. plotcli-original/docs/boxplot.png +0 -0
  28. plotcli-original/docs/density.png +0 -0
  29. plotcli-original/docs/facet.png +0 -0
  30. plotcli-original/docs/facet_grid.png +0 -0
  31. plotcli-original/docs/generate_png.sh +137 -0
  32. plotcli-original/docs/heatmap.png +0 -0
  33. plotcli-original/docs/histogram.png +0 -0
  34. plotcli-original/docs/line.png +0 -0
  35. plotcli-original/docs/noborder.png +0 -0
  36. plotcli-original/docs/scatter.png +0 -0
  37. plotcli-original/docs/showcase.R +182 -0
  38. plotcli-original/inst/doc/ggplotcli.R +231 -0
  39. plotcli-original/inst/doc/ggplotcli.Rmd +329 -0
  40. plotcli-original/inst/doc/ggplotcli.html +1078 -0
  41. plotcli-original/inst/doc/plotcli_class.R +98 -0
  42. plotcli-original/inst/doc/plotcli_class.Rmd +121 -0
  43. plotcli-original/inst/doc/plotcli_class.html +564 -0
  44. plotcli-original/inst/doc/plotcli_wrappers.R +35 -0
  45. plotcli-original/inst/doc/plotcli_wrappers.Rmd +62 -0
  46. plotcli-original/inst/doc/plotcli_wrappers.html +546 -0
  47. plotcli-original/man/AsciiCanvas.Rd +116 -0
  48. plotcli-original/man/BlockCanvas.Rd +132 -0
  49. plotcli-original/man/BrailleCanvas.Rd +146 -0
  50. plotcli-original/man/Canvas.Rd +492 -0
  51. plotcli-original/man/GeomRegistry.Rd +9 -0
  52. plotcli-original/man/add_legend_to_output.Rd +12 -0
  53. plotcli-original/man/braille_dot_bit.Rd +29 -0
  54. plotcli-original/man/braille_set_dot.Rd +21 -0
  55. plotcli-original/man/bresenham.Rd +27 -0
  56. plotcli-original/man/build_plot_output.Rd +28 -0
  57. plotcli-original/man/build_plot_output_v2.Rd +41 -0
  58. plotcli-original/man/cat_plot_matrix.Rd +17 -0
  59. plotcli-original/man/cbind.plotcli.Rd +19 -0
  60. plotcli-original/man/cbind_plots.Rd +17 -0
  61. plotcli-original/man/color_to_term.Rd +18 -0
  62. plotcli-original/man/create_canvas.Rd +21 -0
  63. plotcli-original/man/create_panel_scales.Rd +29 -0
  64. plotcli-original/man/create_scales.Rd +27 -0
  65. plotcli-original/man/dot-geom_registry.Rd +16 -0
  66. plotcli-original/man/draw_border.Rd +12 -0
  67. plotcli-original/man/draw_grid.Rd +12 -0
  68. plotcli-original/man/extract_legend_info.Rd +12 -0
  69. plotcli-original/man/extract_plot_labels.Rd +12 -0
  70. plotcli-original/man/extract_plot_style.Rd +12 -0
  71. plotcli-original/man/format_axis_label.Rd +18 -0
  72. plotcli-original/man/format_four_chars.Rd +21 -0
  73. plotcli-original/man/geom_area_handler.Rd +12 -0
  74. plotcli-original/man/geom_bar_handler.Rd +12 -0
  75. plotcli-original/man/geom_boxplot_handler.Rd +13 -0
  76. plotcli-original/man/geom_density_handler.Rd +12 -0
  77. plotcli-original/man/geom_histogram_handler.Rd +12 -0
  78. plotcli-original/man/geom_hline_handler.Rd +12 -0
  79. plotcli-original/man/geom_line_handler.Rd +12 -0
  80. plotcli-original/man/geom_path_handler.Rd +12 -0
  81. plotcli-original/man/geom_point_handler.Rd +12 -0
  82. plotcli-original/man/geom_rect_handler.Rd +12 -0
  83. plotcli-original/man/geom_segment_handler.Rd +12 -0
  84. plotcli-original/man/geom_smooth_handler.Rd +12 -0
  85. plotcli-original/man/geom_text_handler.Rd +12 -0
  86. plotcli-original/man/geom_vline_handler.Rd +12 -0
  87. plotcli-original/man/get_color_hue.Rd +18 -0
  88. plotcli-original/man/get_data_subset.Rd +23 -0
  89. plotcli-original/man/get_facet_info.Rd +18 -0
  90. plotcli-original/man/get_geom_handler.Rd +17 -0
  91. plotcli-original/man/get_term_colors.Rd +21 -0
  92. plotcli-original/man/ggplotcli.Rd +83 -0
  93. plotcli-original/man/init_color_mapping.Rd +15 -0
  94. plotcli-original/man/is_braille.Rd +20 -0
  95. plotcli-original/man/is_geom_registered.Rd +17 -0
  96. plotcli-original/man/list_registered_geoms.Rd +14 -0
  97. plotcli-original/man/make_colored.Rd +23 -0
  98. plotcli-original/man/make_unique_names.Rd +20 -0
  99. plotcli-original/man/normalize_data.Rd +27 -0
  100. plotcli-original/man/pclib.Rd +48 -0
  101. plotcli-original/man/pclibx.Rd +46 -0
  102. plotcli-original/man/pclid.Rd +44 -0
  103. plotcli-original/man/pclih.Rd +50 -0
  104. plotcli-original/man/pclil.Rd +48 -0
  105. plotcli-original/man/pclis.Rd +48 -0
  106. plotcli-original/man/pixel_to_braille.Rd +23 -0
  107. plotcli-original/man/plotcli.Rd +598 -0
  108. plotcli-original/man/plotcli_bar.Rd +48 -0
  109. plotcli-original/man/plotcli_box.Rd +46 -0
  110. plotcli-original/man/plotcli_density.Rd +44 -0
  111. plotcli-original/man/plotcli_histogram.Rd +50 -0
  112. plotcli-original/man/plotcli_line.Rd +48 -0
  113. plotcli-original/man/plotcli_options.Rd +18 -0
  114. plotcli-original/man/plotcli_scatter.Rd +48 -0
  115. plotcli-original/man/plus-.plotcli.Rd +19 -0
  116. plotcli-original/man/rbind.plotcli.Rd +19 -0
  117. plotcli-original/man/rbind_plots.Rd +17 -0
  118. plotcli-original/man/register_geom.Rd +21 -0
  119. plotcli-original/man/remove_color_codes.Rd +21 -0
  120. plotcli-original/man/render_faceted_plot.Rd +25 -0
  121. plotcli-original/man/render_single_panel.Rd +12 -0
  122. plotcli-original/man/safe_aes_name.Rd +18 -0
  123. plotcli-original/tests/testthat/test-new-geoms.R +136 -0
  124. plotcli-original/tests/testthat/test-plotcli.R +69 -0
  125. plotcli-original/tests/testthat.R +4 -0
  126. plotcli-original/vignettes/ggplotcli.Rmd +329 -0
  127. plotcli-original/vignettes/plotcli_class.R +98 -0
  128. plotcli-original/vignettes/plotcli_class.Rmd +121 -0
  129. plotcli-original/vignettes/plotcli_wrappers.R +35 -0
  130. plotcli-original/vignettes/plotcli_wrappers.Rmd +62 -0
  131. plotcli.egg-info/PKG-INFO +11 -0
  132. plotcli.egg-info/SOURCES.txt +7 -0
  133. plotcli.egg-info/dependency_links.txt +1 -0
  134. plotcli.egg-info/entry_points.txt +3 -0
  135. plotcli.egg-info/top_level.txt +1 -0
  136. plotcli.py +978 -0
  137. plotcli_py-0.1.0.dist-info/METADATA +358 -0
  138. plotcli_py-0.1.0.dist-info/RECORD +143 -0
  139. plotcli_py-0.1.0.dist-info/WHEEL +4 -0
  140. plotcli_py-0.1.0.dist-info/entry_points.txt +2 -0
  141. plotcli_py-0.1.0.dist-info/licenses/LICENSE +21 -0
  142. pyproject.toml +31 -0
  143. uv.lock +8 -0
@@ -0,0 +1 @@
1
+ # to be built
@@ -0,0 +1,416 @@
1
+ #' @title Scatter plot using plotcli
2
+ #' @description Create a scatter plot using plotcli. Short alias: \code{pclis}.
3
+ #' @param x A numeric vector of x values
4
+ #' @param y A numeric vector of y values
5
+ #' @param plot_width Width of the plot (default: 80)
6
+ #' @param plot_height Height of the plot (default: 40)
7
+ #' @param x_label Label for the x-axis (default: "x")
8
+ #' @param y_label Label for the y-axis (default: "y")
9
+ #' @param color Color of the plot elements (default: NULL)
10
+ #' @param braille Use Braille characters for the plot (default: TRUE)
11
+ #' @param name Name of the plot element (default: "scatter")
12
+ #' @param ... Additional arguments passed to the plotcli$new() function
13
+ #' @export
14
+ #'
15
+ #' @examples
16
+ #' x <- rnorm(100)
17
+ #' y <- rnorm(100)
18
+ #' plotcli_scatter(x, y)
19
+ plotcli_scatter <- function(
20
+ y,
21
+ x = NULL,
22
+ plot_width = getOption("plotcli.plot_width", 80),
23
+ plot_height = getOption("plotcli.plot_height", 40),
24
+ x_label = "x",
25
+ y_label = "y",
26
+ color = NULL,
27
+ braille = getOption("plotcli.braille", TRUE),
28
+ name = "scatter",
29
+ ...
30
+ ) {
31
+
32
+ if(is.null(y)) stop("Please provide x and/or y values.")
33
+ if(is.null(x)) x <- 1:length(y)
34
+
35
+ plot <- plotcli$new(
36
+ plot_width = plot_width,
37
+ plot_height = plot_height,
38
+ x_label = x_label,
39
+ y_label = y_label,
40
+ draw_legend = FALSE,
41
+ ...
42
+ )
43
+
44
+ data <- list(x = x, y = y, type = "scatter", color = color, braille = braille, name = name)
45
+ plot$add_data(data)
46
+ return(plot)
47
+
48
+ }
49
+
50
+ #' @title Density plot using plotcli
51
+ #' @description Create a density plot using plotcli. Short alias: \code{pcld}.
52
+ #' @param x A numeric vector of values
53
+ #' @param plot_width Width of the plot (default: 80)
54
+ #' @param plot_height Height of the plot (default: 40)
55
+ #' @param x_label Label for the x-axis (default: "x")
56
+ #' @param y_label Label for the y-axis (default: "Density")
57
+ #' @param color Color of the plot elements (default: NULL)
58
+ #' @param braille Use Braille characters for the plot (default: TRUE)
59
+ #' @param name Name of the plot element (default: "density")
60
+ #' @param ... Additional arguments passed to the plotcli$new() function
61
+ #' @export
62
+ #'
63
+ #' @examples
64
+ #' x <- rnorm(100)
65
+ #' plotcli_density(x)
66
+ plotcli_density <- function(
67
+ x,
68
+ plot_width = getOption("plotcli.plot_width", 80),
69
+ plot_height = getOption("plotcli.plot_height", 40),
70
+ x_label = "x",
71
+ y_label = "Density",
72
+ color = NULL,
73
+ braille = getOption("plotcli.braille", TRUE),
74
+ name = "density",
75
+ ...
76
+ ) {
77
+
78
+ y <- stats::density(x)$y
79
+ x <- stats::density(x)$x
80
+
81
+ plot <- plotcli$new(
82
+ plot_width = plot_width,
83
+ plot_height = plot_height,
84
+ x_label = x_label,
85
+ y_label = y_label,
86
+ draw_legend = FALSE,
87
+ ...
88
+ )
89
+
90
+ data <- list(x = x, y = y, type = "line", color = color, braille = braille, name = name)
91
+ plot$add_data(data)
92
+ return(plot)
93
+
94
+ }
95
+
96
+ #' @title Line plot using plotcli
97
+ #' @description Create a line plot using plotcli. Short alias: \code{pcli}.
98
+ #' @param x A numeric vector of x values
99
+ #' @param y A numeric vector of y values
100
+ #' @param plot_width Width of the plot (default: 80)
101
+ #' @param plot_height Height of the plot (default: 40)
102
+ #' @param x_label Label for the x-axis (default: "x")
103
+ #' @param y_label Label for the y-axis (default: "y")
104
+ #' @param color Color of the plot elements (default: NULL)
105
+ #' @param braille Use Braille characters for the plot (default: TRUE)
106
+ #' @param name Name of the plot element (default: "line")
107
+ #' @param ... Additional arguments passed to the plotcli$new() function
108
+ #' @export
109
+ #'
110
+ #' @examples
111
+ #' x <- 1:10
112
+ #' y <- x^2
113
+ #' plotcli_line(x, y)
114
+ plotcli_line <- function(
115
+ y,
116
+ x = NULL,
117
+ plot_width = getOption("plotcli.plot_width", 80),
118
+ plot_height = getOption("plotcli.plot_height", 40),
119
+ x_label = "x",
120
+ y_label = "y",
121
+ color = NULL,
122
+ braille = getOption("plotcli.braille", TRUE),
123
+ name = "line",
124
+ ...
125
+ ) {
126
+
127
+ if(is.null(y)) stop("Please provide x and/or y values.")
128
+ if(is.null(x)) x <- 1:length(y)
129
+
130
+ plot <- plotcli$new(
131
+ plot_width = plot_width,
132
+ plot_height = plot_height,
133
+ x_label = x_label,
134
+ y_label = y_label,
135
+ draw_legend = FALSE,
136
+ ...
137
+ )
138
+
139
+ data <- list(x = x, y = y, type = "line", color = color, braille = braille, name = name)
140
+ plot$add_data(data)
141
+ return(plot)
142
+
143
+ }
144
+
145
+ #' @title Histogram plot using plotcli
146
+ #' @description Create a histogram plot using plotcli. Short alias: \code{pclih}.
147
+ #' @param x A numeric vector of values
148
+ #' @param plot_width Width of the plot (default: 80)
149
+ #' @param plot_height Height of the plot (default: 40)
150
+ #' @param x_label Label for the x-axis (default: "x")
151
+ #' @param y_label Label for the y-axis (default: "Frequency")
152
+ #' @param color Color of the plot elements (default: NULL)
153
+ #' @param braille Use Braille characters for the plot (default: TRUE)
154
+ #' @param bin_width Width of the bins (default: NULL)
155
+ #' @param ylim y limits (default: NULL)
156
+ #' @param name Name of the plot element (default: "histogram")
157
+ #' @param ... Additional arguments passed to the plotcli$new() function
158
+ #' @export
159
+ #'
160
+ #' @examples
161
+ #' x <- rnorm(100)
162
+ #' plotcli_histogram(x)
163
+ plotcli_histogram <- function(
164
+ x,
165
+ plot_width = getOption("plotcli.plot_width", 80),
166
+ plot_height = getOption("plotcli.plot_height", 40),
167
+ x_label = "x",
168
+ y_label = "Frequency",
169
+ color = NULL,
170
+ braille = getOption("plotcli.braille", TRUE),
171
+ bin_width = NULL,
172
+ ylim = NULL,
173
+ name = "histogram",
174
+ ...
175
+ ) {
176
+
177
+ hist_data <- graphics::hist(
178
+ x,
179
+ plot = FALSE,
180
+ breaks = if (!is.null(bin_width)) seq(min(x), max(x) + bin_width, by = bin_width) else "Sturges"
181
+ )
182
+
183
+ y <- hist_data$counts
184
+ x <- hist_data$mids
185
+
186
+ if(is.null(ylim)) ylim <- c(0, max(y) * 1.05)
187
+
188
+ plot <- plotcli$new(
189
+ plot_width = plot_width,
190
+ plot_height = plot_height,
191
+ x_label = x_label,
192
+ y_label = y_label,
193
+ draw_legend = FALSE,
194
+ ylim = ylim,
195
+ ...
196
+ )
197
+
198
+ data <- list(x = x, y = y, type = "barplot", color = color, braille = braille, name = name)
199
+ plot$add_data(data)
200
+ return(plot)
201
+
202
+ }
203
+
204
+ #' @title Bar plot using plotcli
205
+ #' @description Create a bar plot using plotcli. Short alias: \code{pclb}.
206
+ #' @param x A vector of categories
207
+ #' @param y A numeric vector of values
208
+ #' @param plot_width Width of the plot (default: 80)
209
+ #' @param plot_height Height of the plot (default: 40)
210
+ #' @param x_label Label for the x-axis (default: "x")
211
+ #' @param y_label Label for the y-axis (default: "y")
212
+ #' @param color Color of the plot elements (default: NULL)
213
+ #' @param braille Use Braille characters for the plot (default: TRUE)
214
+ #' @param name Name of the plot element (default: "barplot")
215
+ #' @param ... Additional arguments passed to the plotcli$new() function
216
+ #' @export
217
+ #'
218
+ #' @examples
219
+ #' x <- 1:5
220
+ #' y <- c(10, 15, 8, 12, 6)
221
+ #' plotcli_bar(x, y)
222
+ plotcli_bar <- function(
223
+ y,
224
+ x = NULL,
225
+ plot_width = getOption("plotcli.plot_width", 80),
226
+ plot_height = getOption("plotcli.plot_height", 40),
227
+ x_label = "x",
228
+ y_label = "y",
229
+ color = NULL,
230
+ braille = getOption("plotcli.braille", TRUE),
231
+ name = "barplot",
232
+ ...
233
+ ) {
234
+
235
+ if(is.null(y)) stop("Please provide x and/or y values.")
236
+ if(is.null(x)) x <- 1:length(y)
237
+
238
+ plot <- plotcli$new(
239
+ plot_width = plot_width,
240
+ plot_height = plot_height,
241
+ x_label = x_label,
242
+ y_label = y_label,
243
+ draw_legend = FALSE,
244
+ ...
245
+ )
246
+
247
+
248
+ data <- list(x = x, y = y, type = "barplot", color = color, braille = braille, name = name)
249
+ plot$add_data(data)
250
+ return(plot)
251
+
252
+ }
253
+
254
+ #' @title Box plot using plotcli
255
+ #' @description Create a box plot using plotcli. Short alias: \code{pclbx}.
256
+ #' @param x A vector of categories
257
+ #' @param y A list of numeric vectors of values
258
+ #' @param plot_width Width of the plot (default: 80)
259
+ #' @param plot_height Height of the plot (default: 40)
260
+ #' @param x_label Label for the x-axis (default: "x")
261
+ #' @param y_label Label for the y-axis (default: "y")
262
+ #' @param color Color of the plot elements (default: NULL)
263
+ #' @param braille Use Braille characters for the plot (default: TRUE)
264
+ #' @param name Name of the plot element (default: "boxplot")
265
+ #' @param ... Additional arguments passed to the plotcli$new() function
266
+ #' @export
267
+ #'
268
+ #' @examples
269
+ #' y <- rnorm(50, mean = 0)
270
+ #' plotcli_box(y)
271
+ plotcli_box <- function(
272
+ y,
273
+ plot_width = getOption("plotcli.plot_width", 80),
274
+ plot_height = getOption("plotcli.plot_height", 40),
275
+ x_label = "x",
276
+ y_label = "y",
277
+ color = NULL,
278
+ braille = getOption("plotcli.braille", TRUE),
279
+ name = "boxplot",
280
+ ...
281
+ ) {
282
+
283
+ plot <- plotcli$new(
284
+ plot_width = plot_width,
285
+ plot_height = plot_height,
286
+ x_label = x_label,
287
+ y_label = y_label,
288
+ draw_legend = FALSE,
289
+ ...
290
+ )
291
+
292
+ x = rep(1, length(y))
293
+ data <- list(x = x, y = y, type = "boxplot", color = color, braille = braille, name = name)
294
+ plot$add_data(data)
295
+ return(plot)
296
+
297
+ }
298
+
299
+ # short versions
300
+
301
+ #' @title Short version of plotcli_scatter
302
+ #' @description Short version of plotcli_scatter function.
303
+ #' @param x A numeric vector of x values
304
+ #' @param y A numeric vector of y values
305
+ #' @param plot_width Width of the plot (default: 80)
306
+ #' @param plot_height Height of the plot (default: 40)
307
+ #' @param x_label Label for the x-axis (default: "x")
308
+ #' @param y_label Label for the y-axis (default: "y")
309
+ #' @param color Color of the plot elements (default: NULL)
310
+ #' @param braille Use Braille characters for the plot (default: TRUE)
311
+ #' @param name Name of the plot element (default: "scatter")
312
+ #' @param ... Additional arguments passed to the plotcli$new() function
313
+ #' @export
314
+ #'
315
+ #' @examples
316
+ #' x <- rnorm(100)
317
+ #' y <- rnorm(100)
318
+ #' pclis(x, y)
319
+ pclis <- plotcli_scatter
320
+
321
+ #' @title Short version of plotcli_density
322
+ #' @description Short version of plotcli_density function.
323
+ #' @param x A numeric vector of values
324
+ #' @param plot_width Width of the plot (default: 80)
325
+ #' @param plot_height Height of the plot (default: 40)
326
+ #' @param x_label Label for the x-axis (default: "x")
327
+ #' @param y_label Label for the y-axis (default: "Density")
328
+ #' @param color Color of the plot elements (default: NULL)
329
+ #' @param braille Use Braille characters for the plot (default: TRUE)
330
+ #' @param name Name of the plot element (default: "density")
331
+ #' @param ... Additional arguments passed to the plotcli$new() function
332
+ #' @export
333
+ #'
334
+ #' @examples
335
+ #' x <- rnorm(100)
336
+ #' pclid(x)
337
+ pclid <- plotcli_density
338
+
339
+ #' @title Short version of plotcli_line
340
+ #' @description Short version of plotcli_line function.
341
+ #' @param x A numeric vector of x values
342
+ #' @param y A numeric vector of y values
343
+ #' @param plot_width Width of the plot (default: 80)
344
+ #' @param plot_height Height of the plot (default: 40)
345
+ #' @param x_label Label for the x-axis (default: "x")
346
+ #' @param y_label Label for the y-axis (default: "y")
347
+ #' @param color Color of the plot elements (default: NULL)
348
+ #' @param braille Use Braille characters for the plot (default: TRUE)
349
+ #' @param name Name of the plot element (default: "line")
350
+ #' @param ... Additional arguments passed to the plotcli$new() function
351
+ #' @export
352
+ #'
353
+ #' @examples
354
+ #' x <- 1:10
355
+ #' y <- x^2
356
+ #' pclil(x, y)
357
+ pclil <- plotcli_line
358
+
359
+ #' @title Short version of plotcli_histogram
360
+ #' @description Short version of plotcli_histogram function.
361
+ #' @param x A numeric vector of values
362
+ #' @param plot_width Width of the plot (default: 80)
363
+ #' @param plot_height Height of the plot (default: 40)
364
+ #' @param x_label Label for the x-axis (default: "x")
365
+ #' @param y_label Label for the y-axis (default: "Frequency")
366
+ #' @param color Color of the plot elements (default: NULL)
367
+ #' @param braille Use Braille characters for the plot (default: TRUE)
368
+ #' @param bin_width Width of the bins (default: NULL)
369
+ #' @param ylim y limits (default: NULL)
370
+ #' @param name Name of the plot element (default: "histogram")
371
+ #' @param ... Additional arguments passed to the plotcli$new() function
372
+ #' @export
373
+ #'
374
+ #' @examples
375
+ #' x <- rnorm(100)
376
+ #' pclih(x)
377
+ pclih <- plotcli_histogram
378
+
379
+ #' @title Short version of plotcli_bar
380
+ #' @description Short version of plotcli_bar function.
381
+ #' @param x A vector of categories
382
+ #' @param y A numeric vector of values
383
+ #' @param plot_width Width of the plot (default: 80)
384
+ #' @param plot_height Height of the plot (default: 40)
385
+ #' @param x_label Label for the x-axis (default: "x")
386
+ #' @param y_label Label for the y-axis (default: "y")
387
+ #' @param color Color of the plot elements (default: NULL)
388
+ #' @param braille Use Braille characters for the plot (default: TRUE)
389
+ #' @param name Name of the plot element (default: "barplot")
390
+ #' @param ... Additional arguments passed to the plotcli$new() function
391
+ #' @export
392
+ #'
393
+ #' @examples
394
+ #' x <- 1:5
395
+ #' y <- c(10, 15, 8, 12, 6)
396
+ #' pclib(x, y)
397
+ pclib <- plotcli_bar
398
+
399
+ #' @title Short version of plotcli_box
400
+ #' @description Short version of plotcli_box function.
401
+ #' @param x A vector of categories
402
+ #' @param y A list of numeric vectors of values
403
+ #' @param plot_width Width of the plot (default: 80)
404
+ #' @param plot_height Height of the plot (default: 40)
405
+ #' @param x_label Label for the x-axis (default: "x")
406
+ #' @param y_label Label for the y-axis (default: "y")
407
+ #' @param color Color of the plot elements (default: NULL)
408
+ #' @param braille Use Braille characters for the plot (default: TRUE)
409
+ #' @param name Name of the plot element (default: "boxplot")
410
+ #' @param ... Additional arguments passed to the plotcli$new() function
411
+ #' @export
412
+ #'
413
+ #' @examples
414
+ #' y <- rnorm(50, mean = 0)
415
+ #' pclib(y)
416
+ pclibx <- plotcli_box
@@ -0,0 +1,15 @@
1
+ .onLoad <- function(libname, pkgname) {
2
+ # Enable crayon colors even in non-interactive sessions (e.g., Rscript)
3
+ # This ensures colored output works when running scripts
4
+ if (is.null(getOption("crayon.enabled"))) {
5
+ options(crayon.enabled = TRUE)
6
+ }
7
+ }
8
+
9
+ .onAttach <- function(libname, pkgname) {
10
+ # Set default options
11
+ plotcli_options(plot_width = 60, plot_height = 20, braille = FALSE)
12
+
13
+ # Display a startup message
14
+ packageStartupMessage("plotcli loaded. Use plotcli_options() to set global options.")
15
+ }
@@ -0,0 +1,192 @@
1
+ # plotcli: ggplot2 in Your Terminal
2
+
3
+ [![CRAN status](https://www.r-pkg.org/badges/version/plotcli?color=green)](https://CRAN.R-project.org/package=plotcli)
4
+ [![CRAN checks](https://badges.cranchecks.info/worst/plotcli.svg)](https://cran.r-project.org/web/checks/check_results_plotcli.html)
5
+ [![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/plotcli)](https://www.r-pkg.org/pkg/plotcli)
6
+ [![Downloads](https://cranlogs.r-pkg.org/badges/plotcli?color=blue)](https://www.r-pkg.org/pkg/plotcli)
7
+
8
+ <p align="center">
9
+ <img src="docs/scatter.png" alt="plotcli: colored scatter plot in terminal" width="700">
10
+ </p>
11
+
12
+ plotcli renders ggplot2 plots directly in the terminal using Unicode Braille characters and ANSI colors.
13
+ Write your ggplot code as usual, then call `ggplotcli()` to see it in the console -- no graphics device needed.
14
+
15
+ Inspired by the excellent [UnicodePlots.jl](https://github.com/JuliaPlots/UnicodePlots.jl).
16
+
17
+ ## Installation
18
+
19
+ ```r
20
+ # From CRAN
21
+ install.packages("plotcli")
22
+
23
+ # Development version from GitHub
24
+ remotes::install_github("cheuerde/plotcli")
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ Any ggplot2 plot works. Build your plot as usual, then pass it to `ggplotcli()`:
30
+
31
+ ```r
32
+ library(plotcli)
33
+ library(ggplot2)
34
+
35
+ p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) +
36
+ geom_point() +
37
+ labs(title = "MPG vs Weight by Cylinders",
38
+ x = "Weight (1000 lbs)", y = "Miles per Gallon",
39
+ color = "Cylinders") +
40
+ theme_bw()
41
+
42
+ ggplotcli(p)
43
+ ```
44
+
45
+ <p align="center">
46
+ <img src="docs/scatter.png" alt="Scatter plot with colored groups" width="700">
47
+ </p>
48
+
49
+ ## Gallery
50
+
51
+ ### Boxplots
52
+
53
+ ```r
54
+ p <- ggplot(df, aes(x = group, y = value, fill = group)) +
55
+ geom_boxplot() +
56
+ labs(title = "Distribution Comparison by Group")
57
+ ggplotcli(p)
58
+ ```
59
+
60
+ <p align="center">
61
+ <img src="docs/boxplot.png" alt="Boxplot" width="700">
62
+ </p>
63
+
64
+ ### Line Charts
65
+
66
+ ```r
67
+ p <- ggplot(economics, aes(x = date, y = unemploy)) +
68
+ geom_line(color = "steelblue") +
69
+ geom_smooth(color = "red", se = FALSE) +
70
+ labs(title = "US Unemployment Over Time")
71
+ ggplotcli(p)
72
+ ```
73
+
74
+ <p align="center">
75
+ <img src="docs/line.png" alt="Line chart" width="700">
76
+ </p>
77
+
78
+ ### Bar Charts
79
+
80
+ <p align="center">
81
+ <img src="docs/bar.png" alt="Bar chart" width="700">
82
+ </p>
83
+
84
+ ### Histograms
85
+
86
+ <p align="center">
87
+ <img src="docs/histogram.png" alt="Histogram" width="700">
88
+ </p>
89
+
90
+ ### Density Plots
91
+
92
+ <p align="center">
93
+ <img src="docs/density.png" alt="Density plot" width="700">
94
+ </p>
95
+
96
+ ### Heatmaps
97
+
98
+ ```r
99
+ cor_mat <- cor(mtcars[, c("mpg", "cyl", "disp", "hp", "wt", "qsec")])
100
+ df <- as.data.frame(as.table(cor_mat))
101
+ names(df) <- c("Var1", "Var2", "value")
102
+ p <- ggplot(df, aes(Var1, Var2, fill = value)) +
103
+ geom_tile() +
104
+ labs(title = "Correlation Heatmap", fill = "correlation")
105
+ ggplotcli(p)
106
+ ```
107
+
108
+ <p align="center">
109
+ <img src="docs/heatmap.png" alt="Heatmap" width="700">
110
+ </p>
111
+
112
+ ### Faceted Plots
113
+
114
+ ```r
115
+ p <- ggplot(mpg, aes(x = displ, y = hwy)) +
116
+ geom_point(color = "steelblue") +
117
+ geom_smooth(method = "lm", color = "red", se = FALSE) +
118
+ facet_wrap(~drv) +
119
+ theme_bw()
120
+ ggplotcli(p, width = 80, height = 18)
121
+ ```
122
+
123
+ <p align="center">
124
+ <img src="docs/facet.png" alt="Faceted plot" width="700">
125
+ </p>
126
+
127
+ ### Canvas Types
128
+
129
+ **Block canvas** -- medium resolution using block characters:
130
+ <p align="center">
131
+ <img src="docs/block.png" alt="Block canvas" width="600">
132
+ </p>
133
+
134
+ **ASCII canvas** -- basic ASCII for maximum compatibility:
135
+ <p align="center">
136
+ <img src="docs/ascii.png" alt="ASCII canvas" width="600">
137
+ </p>
138
+
139
+ ## Supported Geoms (27)
140
+
141
+ | Geom | Status |
142
+ |------|--------|
143
+ | `geom_point` | :white_check_mark: |
144
+ | `geom_line`, `geom_path` | :white_check_mark: |
145
+ | `geom_step` | :white_check_mark: |
146
+ | `geom_bar`, `geom_col`, `geom_histogram` | :white_check_mark: |
147
+ | `geom_boxplot` | :white_check_mark: |
148
+ | `geom_violin` | :white_check_mark: |
149
+ | `geom_density` | :white_check_mark: |
150
+ | `geom_smooth` | :white_check_mark: |
151
+ | `geom_area` | :white_check_mark: |
152
+ | `geom_ribbon` | :white_check_mark: |
153
+ | `geom_segment`, `geom_hline`, `geom_vline`, `geom_abline` | :white_check_mark: |
154
+ | `geom_errorbar`, `geom_linerange`, `geom_pointrange`, `geom_crossbar` | :white_check_mark: |
155
+ | `geom_rect`, `geom_tile`, `geom_raster` (heatmaps) | :white_check_mark: |
156
+ | `geom_text`, `geom_label` | :white_check_mark: |
157
+ | `geom_rug` | :white_check_mark: |
158
+ | `facet_wrap`, `facet_grid` | :white_check_mark: |
159
+
160
+ ## Options
161
+
162
+ ```r
163
+ # Control size
164
+ ggplotcli(p, width = 80, height = 24)
165
+
166
+ # Canvas types
167
+ ggplotcli(p, canvas_type = "braille") # High resolution (default)
168
+ ggplotcli(p, canvas_type = "block") # Block characters
169
+ ggplotcli(p, canvas_type = "ascii") # ASCII only
170
+ ```
171
+
172
+ ## Direct R6 Class Usage
173
+
174
+ For lower-level control, use the `plotcli` R6 class directly:
175
+
176
+ ```r
177
+ pc <- plotcli$new(plot_width = 60, plot_height = 20, x_label = "wt", y_label = "mpg",
178
+ title = "MPG vs Weight")
179
+ pc$add_data(list(x = mtcars$wt, y = mtcars$mpg, type = "scatter", name = "mtcars"))
180
+ pc$print_plot()
181
+ ```
182
+
183
+ ## Similar Projects
184
+
185
+ - [txtplot](https://github.com/bbnkmp/txtplot/): The OG in R
186
+ - [r-plot](https://github.com/geotheory/r-plot): Collection of excellent terminal plotting functions
187
+ - [UnicodePlots.jl](https://github.com/JuliaPlots/UnicodePlots.jl): The gold standard for terminal graphics
188
+ - [plotext](https://github.com/piccolomo/plotext): Powerful terminal graphics in Python
189
+
190
+ ## License
191
+
192
+ `plotcli` is released under the LGPL-3 License.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file