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,44 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/plotcli_wrappers.r
|
|
3
|
+
\name{plotcli_density}
|
|
4
|
+
\alias{plotcli_density}
|
|
5
|
+
\title{Density plot using plotcli}
|
|
6
|
+
\usage{
|
|
7
|
+
plotcli_density(
|
|
8
|
+
x,
|
|
9
|
+
plot_width = getOption("plotcli.plot_width", 80),
|
|
10
|
+
plot_height = getOption("plotcli.plot_height", 40),
|
|
11
|
+
x_label = "x",
|
|
12
|
+
y_label = "Density",
|
|
13
|
+
color = NULL,
|
|
14
|
+
braille = getOption("plotcli.braille", TRUE),
|
|
15
|
+
name = "density",
|
|
16
|
+
...
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
\arguments{
|
|
20
|
+
\item{x}{A numeric vector of values}
|
|
21
|
+
|
|
22
|
+
\item{plot_width}{Width of the plot (default: 80)}
|
|
23
|
+
|
|
24
|
+
\item{plot_height}{Height of the plot (default: 40)}
|
|
25
|
+
|
|
26
|
+
\item{x_label}{Label for the x-axis (default: "x")}
|
|
27
|
+
|
|
28
|
+
\item{y_label}{Label for the y-axis (default: "Density")}
|
|
29
|
+
|
|
30
|
+
\item{color}{Color of the plot elements (default: NULL)}
|
|
31
|
+
|
|
32
|
+
\item{braille}{Use Braille characters for the plot (default: TRUE)}
|
|
33
|
+
|
|
34
|
+
\item{name}{Name of the plot element (default: "density")}
|
|
35
|
+
|
|
36
|
+
\item{...}{Additional arguments passed to the plotcli$new() function}
|
|
37
|
+
}
|
|
38
|
+
\description{
|
|
39
|
+
Create a density plot using plotcli. Short alias: \code{pcld}.
|
|
40
|
+
}
|
|
41
|
+
\examples{
|
|
42
|
+
x <- rnorm(100)
|
|
43
|
+
plotcli_density(x)
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/plotcli_wrappers.r
|
|
3
|
+
\name{plotcli_histogram}
|
|
4
|
+
\alias{plotcli_histogram}
|
|
5
|
+
\title{Histogram plot using plotcli}
|
|
6
|
+
\usage{
|
|
7
|
+
plotcli_histogram(
|
|
8
|
+
x,
|
|
9
|
+
plot_width = getOption("plotcli.plot_width", 80),
|
|
10
|
+
plot_height = getOption("plotcli.plot_height", 40),
|
|
11
|
+
x_label = "x",
|
|
12
|
+
y_label = "Frequency",
|
|
13
|
+
color = NULL,
|
|
14
|
+
braille = getOption("plotcli.braille", TRUE),
|
|
15
|
+
bin_width = NULL,
|
|
16
|
+
ylim = NULL,
|
|
17
|
+
name = "histogram",
|
|
18
|
+
...
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
\arguments{
|
|
22
|
+
\item{x}{A numeric vector of values}
|
|
23
|
+
|
|
24
|
+
\item{plot_width}{Width of the plot (default: 80)}
|
|
25
|
+
|
|
26
|
+
\item{plot_height}{Height of the plot (default: 40)}
|
|
27
|
+
|
|
28
|
+
\item{x_label}{Label for the x-axis (default: "x")}
|
|
29
|
+
|
|
30
|
+
\item{y_label}{Label for the y-axis (default: "Frequency")}
|
|
31
|
+
|
|
32
|
+
\item{color}{Color of the plot elements (default: NULL)}
|
|
33
|
+
|
|
34
|
+
\item{braille}{Use Braille characters for the plot (default: TRUE)}
|
|
35
|
+
|
|
36
|
+
\item{bin_width}{Width of the bins (default: NULL)}
|
|
37
|
+
|
|
38
|
+
\item{ylim}{y limits (default: NULL)}
|
|
39
|
+
|
|
40
|
+
\item{name}{Name of the plot element (default: "histogram")}
|
|
41
|
+
|
|
42
|
+
\item{...}{Additional arguments passed to the plotcli$new() function}
|
|
43
|
+
}
|
|
44
|
+
\description{
|
|
45
|
+
Create a histogram plot using plotcli. Short alias: \code{pclih}.
|
|
46
|
+
}
|
|
47
|
+
\examples{
|
|
48
|
+
x <- rnorm(100)
|
|
49
|
+
plotcli_histogram(x)
|
|
50
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/plotcli_wrappers.r
|
|
3
|
+
\name{plotcli_line}
|
|
4
|
+
\alias{plotcli_line}
|
|
5
|
+
\title{Line plot using plotcli}
|
|
6
|
+
\usage{
|
|
7
|
+
plotcli_line(
|
|
8
|
+
y,
|
|
9
|
+
x = NULL,
|
|
10
|
+
plot_width = getOption("plotcli.plot_width", 80),
|
|
11
|
+
plot_height = getOption("plotcli.plot_height", 40),
|
|
12
|
+
x_label = "x",
|
|
13
|
+
y_label = "y",
|
|
14
|
+
color = NULL,
|
|
15
|
+
braille = getOption("plotcli.braille", TRUE),
|
|
16
|
+
name = "line",
|
|
17
|
+
...
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
\arguments{
|
|
21
|
+
\item{y}{A numeric vector of y values}
|
|
22
|
+
|
|
23
|
+
\item{x}{A numeric vector of x values}
|
|
24
|
+
|
|
25
|
+
\item{plot_width}{Width of the plot (default: 80)}
|
|
26
|
+
|
|
27
|
+
\item{plot_height}{Height of the plot (default: 40)}
|
|
28
|
+
|
|
29
|
+
\item{x_label}{Label for the x-axis (default: "x")}
|
|
30
|
+
|
|
31
|
+
\item{y_label}{Label for the y-axis (default: "y")}
|
|
32
|
+
|
|
33
|
+
\item{color}{Color of the plot elements (default: NULL)}
|
|
34
|
+
|
|
35
|
+
\item{braille}{Use Braille characters for the plot (default: TRUE)}
|
|
36
|
+
|
|
37
|
+
\item{name}{Name of the plot element (default: "line")}
|
|
38
|
+
|
|
39
|
+
\item{...}{Additional arguments passed to the plotcli$new() function}
|
|
40
|
+
}
|
|
41
|
+
\description{
|
|
42
|
+
Create a line plot using plotcli. Short alias: \code{pcli}.
|
|
43
|
+
}
|
|
44
|
+
\examples{
|
|
45
|
+
x <- 1:10
|
|
46
|
+
y <- x^2
|
|
47
|
+
plotcli_line(x, y)
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/helper_functions.r
|
|
3
|
+
\name{plotcli_options}
|
|
4
|
+
\alias{plotcli_options}
|
|
5
|
+
\title{Set global options for plotcli}
|
|
6
|
+
\usage{
|
|
7
|
+
plotcli_options(plot_width = 60, plot_height = 20, braille = FALSE)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{plot_width}{Default plot width (default: 60)}
|
|
11
|
+
|
|
12
|
+
\item{plot_height}{Default plot height (default: 20)}
|
|
13
|
+
|
|
14
|
+
\item{braille}{Default braille setting (default: FALSE)}
|
|
15
|
+
}
|
|
16
|
+
\description{
|
|
17
|
+
Set global options for plotcli
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/plotcli_wrappers.r
|
|
3
|
+
\name{plotcli_scatter}
|
|
4
|
+
\alias{plotcli_scatter}
|
|
5
|
+
\title{Scatter plot using plotcli}
|
|
6
|
+
\usage{
|
|
7
|
+
plotcli_scatter(
|
|
8
|
+
y,
|
|
9
|
+
x = NULL,
|
|
10
|
+
plot_width = getOption("plotcli.plot_width", 80),
|
|
11
|
+
plot_height = getOption("plotcli.plot_height", 40),
|
|
12
|
+
x_label = "x",
|
|
13
|
+
y_label = "y",
|
|
14
|
+
color = NULL,
|
|
15
|
+
braille = getOption("plotcli.braille", TRUE),
|
|
16
|
+
name = "scatter",
|
|
17
|
+
...
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
\arguments{
|
|
21
|
+
\item{y}{A numeric vector of y values}
|
|
22
|
+
|
|
23
|
+
\item{x}{A numeric vector of x values}
|
|
24
|
+
|
|
25
|
+
\item{plot_width}{Width of the plot (default: 80)}
|
|
26
|
+
|
|
27
|
+
\item{plot_height}{Height of the plot (default: 40)}
|
|
28
|
+
|
|
29
|
+
\item{x_label}{Label for the x-axis (default: "x")}
|
|
30
|
+
|
|
31
|
+
\item{y_label}{Label for the y-axis (default: "y")}
|
|
32
|
+
|
|
33
|
+
\item{color}{Color of the plot elements (default: NULL)}
|
|
34
|
+
|
|
35
|
+
\item{braille}{Use Braille characters for the plot (default: TRUE)}
|
|
36
|
+
|
|
37
|
+
\item{name}{Name of the plot element (default: "scatter")}
|
|
38
|
+
|
|
39
|
+
\item{...}{Additional arguments passed to the plotcli$new() function}
|
|
40
|
+
}
|
|
41
|
+
\description{
|
|
42
|
+
Create a scatter plot using plotcli. Short alias: \code{pclis}.
|
|
43
|
+
}
|
|
44
|
+
\examples{
|
|
45
|
+
x <- rnorm(100)
|
|
46
|
+
y <- rnorm(100)
|
|
47
|
+
plotcli_scatter(x, y)
|
|
48
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/class_functions.r
|
|
3
|
+
\name{+.plotcli}
|
|
4
|
+
\alias{+.plotcli}
|
|
5
|
+
\title{Overload the "+" operator for plotcli objects}
|
|
6
|
+
\usage{
|
|
7
|
+
\method{+}{plotcli}(plot1, plot2)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{plot1}{A plotcli object to be merged.}
|
|
11
|
+
|
|
12
|
+
\item{plot2}{A plotcli object to be merged.}
|
|
13
|
+
}
|
|
14
|
+
\value{
|
|
15
|
+
A new plotcli object containing the combined data from both objects.
|
|
16
|
+
}
|
|
17
|
+
\description{
|
|
18
|
+
This function overloads the "+" operator to merge two plotcli objects.
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/class_functions.r
|
|
3
|
+
\name{rbind.plotcli}
|
|
4
|
+
\alias{rbind.plotcli}
|
|
5
|
+
\title{Generic function for combining plotcli objects vertically}
|
|
6
|
+
\usage{
|
|
7
|
+
\method{rbind}{plotcli}(..., deparse.level = 1)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{...}{plotcli objects to be combined.}
|
|
11
|
+
|
|
12
|
+
\item{deparse.level}{The deparsing level for the arguments.}
|
|
13
|
+
}
|
|
14
|
+
\value{
|
|
15
|
+
A combined plot matrix.
|
|
16
|
+
}
|
|
17
|
+
\description{
|
|
18
|
+
Generic function for combining plotcli objects vertically
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/class_functions.r
|
|
3
|
+
\name{rbind_plots}
|
|
4
|
+
\alias{rbind_plots}
|
|
5
|
+
\title{Combine plot matrices vertically}
|
|
6
|
+
\usage{
|
|
7
|
+
rbind_plots(...)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{...}{A list of plot matrices to be combined.}
|
|
11
|
+
}
|
|
12
|
+
\value{
|
|
13
|
+
A combined plot matrix.
|
|
14
|
+
}
|
|
15
|
+
\description{
|
|
16
|
+
This function combines multiple plot matrices vertically, centering them horizontally.
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/geom_registry.r
|
|
3
|
+
\name{register_geom}
|
|
4
|
+
\alias{register_geom}
|
|
5
|
+
\title{Register a Geom Handler}
|
|
6
|
+
\usage{
|
|
7
|
+
register_geom(geom_name, handler)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{geom_name}{Name of the geom (e.g., "GeomPoint", "GeomLine")}
|
|
11
|
+
|
|
12
|
+
\item{handler}{Function that takes (data, canvas, scales, params) and draws to canvas}
|
|
13
|
+
}
|
|
14
|
+
\description{
|
|
15
|
+
Register a function that can render a specific ggplot2 geom to a canvas.
|
|
16
|
+
}
|
|
17
|
+
\examples{
|
|
18
|
+
register_geom("GeomPoint", function(data, canvas, scales, params) {
|
|
19
|
+
# Draw points on canvas
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/helper_functions.r
|
|
3
|
+
\name{remove_color_codes}
|
|
4
|
+
\alias{remove_color_codes}
|
|
5
|
+
\title{Remove color codes from a string}
|
|
6
|
+
\usage{
|
|
7
|
+
remove_color_codes(s)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{s}{The text string containing ANSI color codes.}
|
|
11
|
+
}
|
|
12
|
+
\value{
|
|
13
|
+
A text string with ANSI color codes removed.
|
|
14
|
+
}
|
|
15
|
+
\description{
|
|
16
|
+
This function removes ANSI color codes from a given text string.
|
|
17
|
+
}
|
|
18
|
+
\examples{
|
|
19
|
+
colored_text <- make_colored("Hello, world!", "blue")
|
|
20
|
+
remove_color_codes(colored_text)
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/ggplotcli_helpers.r
|
|
3
|
+
\name{render_faceted_plot}
|
|
4
|
+
\alias{render_faceted_plot}
|
|
5
|
+
\title{Render Faceted Plot}
|
|
6
|
+
\usage{
|
|
7
|
+
render_faceted_plot(built, facet_info, width, height, canvas_type, style_opts)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{built}{Result from ggplot_build}
|
|
11
|
+
|
|
12
|
+
\item{facet_info}{Facet information from get_facet_info}
|
|
13
|
+
|
|
14
|
+
\item{width}{Total width}
|
|
15
|
+
|
|
16
|
+
\item{height}{Total height}
|
|
17
|
+
|
|
18
|
+
\item{canvas_type}{Canvas type}
|
|
19
|
+
|
|
20
|
+
\item{style_opts}{Style options}
|
|
21
|
+
}
|
|
22
|
+
\description{
|
|
23
|
+
Render Faceted Plot
|
|
24
|
+
}
|
|
25
|
+
\keyword{internal}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/ggplotcli_helpers.r
|
|
3
|
+
\name{render_single_panel}
|
|
4
|
+
\alias{render_single_panel}
|
|
5
|
+
\title{Render a single panel (non-faceted) plot}
|
|
6
|
+
\usage{
|
|
7
|
+
render_single_panel(built, width, height, canvas_type, style_opts)
|
|
8
|
+
}
|
|
9
|
+
\description{
|
|
10
|
+
Render a single panel (non-faceted) plot
|
|
11
|
+
}
|
|
12
|
+
\keyword{internal}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
% Generated by roxygen2: do not edit by hand
|
|
2
|
+
% Please edit documentation in R/ggplotcli.r
|
|
3
|
+
\name{safe_aes_name}
|
|
4
|
+
\alias{safe_aes_name}
|
|
5
|
+
\title{Safely extract aesthetic name from ggplot mapping}
|
|
6
|
+
\usage{
|
|
7
|
+
safe_aes_name(aes_expr)
|
|
8
|
+
}
|
|
9
|
+
\arguments{
|
|
10
|
+
\item{aes_expr}{The aesthetic expression (can be a quosure)}
|
|
11
|
+
}
|
|
12
|
+
\value{
|
|
13
|
+
Character string of the column name, or NULL
|
|
14
|
+
}
|
|
15
|
+
\description{
|
|
16
|
+
Handles quosures, simple symbols, and calls like factor(cyl)
|
|
17
|
+
}
|
|
18
|
+
\keyword{internal}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
library(testthat)
|
|
2
|
+
library(plotcli)
|
|
3
|
+
library(ggplot2)
|
|
4
|
+
|
|
5
|
+
test_that("GeomTile works", {
|
|
6
|
+
df_tile <- expand.grid(x = 1:5, y = 1:5)
|
|
7
|
+
df_tile$z <- runif(25)
|
|
8
|
+
p <- ggplot(df_tile, aes(x, y, fill = z)) + geom_tile()
|
|
9
|
+
|
|
10
|
+
expect_output(res <- ggplotcli(p))
|
|
11
|
+
expect_s3_class(res, "Canvas")
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test_that("GeomPolygon warns about missing handler", {
|
|
15
|
+
ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
|
|
16
|
+
values <- data.frame(
|
|
17
|
+
id = ids,
|
|
18
|
+
value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
|
|
19
|
+
)
|
|
20
|
+
positions <- data.frame(
|
|
21
|
+
id = rep(ids, each = 4),
|
|
22
|
+
x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3, 0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
|
|
23
|
+
y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5, 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
|
|
24
|
+
)
|
|
25
|
+
datapoly <- merge(values, positions, by = c("id"))
|
|
26
|
+
p <- ggplot(datapoly, aes(x = x, y = y)) + geom_polygon(aes(fill = value, group = id))
|
|
27
|
+
|
|
28
|
+
expect_warning(res <- ggplotcli(p), "No handler registered for geom: GeomPolygon")
|
|
29
|
+
expect_s3_class(res, "Canvas")
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test_that("Faceting works", {
|
|
33
|
+
p <- ggplot(mtcars, aes(x = mpg, y = wt)) +
|
|
34
|
+
geom_point() +
|
|
35
|
+
facet_wrap(~ cyl)
|
|
36
|
+
|
|
37
|
+
expect_output(res <- ggplotcli(p))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test_that("GeomBar works", {
|
|
41
|
+
p <- ggplot(mtcars, aes(x = factor(cyl))) + geom_bar()
|
|
42
|
+
expect_output(res <- ggplotcli(p))
|
|
43
|
+
expect_s3_class(res, "Canvas")
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test_that("GeomStep works", {
|
|
47
|
+
df <- data.frame(x = 1:10, y = cumsum(rnorm(10)))
|
|
48
|
+
p <- ggplot(df, aes(x, y)) + geom_step()
|
|
49
|
+
expect_output(res <- ggplotcli(p))
|
|
50
|
+
expect_s3_class(res, "Canvas")
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test_that("GeomAbline works", {
|
|
54
|
+
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() +
|
|
55
|
+
geom_abline(intercept = 37, slope = -5, color = "red")
|
|
56
|
+
expect_output(res <- ggplotcli(p))
|
|
57
|
+
expect_s3_class(res, "Canvas")
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test_that("GeomRibbon works", {
|
|
61
|
+
df <- data.frame(x = 1:20, y = sin(1:20 / 3),
|
|
62
|
+
ymin = sin(1:20 / 3) - 0.5, ymax = sin(1:20 / 3) + 0.5)
|
|
63
|
+
p <- ggplot(df, aes(x, y)) +
|
|
64
|
+
geom_ribbon(aes(ymin = ymin, ymax = ymax), fill = "steelblue") +
|
|
65
|
+
geom_line()
|
|
66
|
+
expect_output(res <- ggplotcli(p))
|
|
67
|
+
expect_s3_class(res, "Canvas")
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test_that("GeomSmooth with ribbon works", {
|
|
71
|
+
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() +
|
|
72
|
+
geom_smooth(method = "lm")
|
|
73
|
+
expect_output(res <- suppressMessages(ggplotcli(p)))
|
|
74
|
+
expect_s3_class(res, "Canvas")
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test_that("GeomErrorbar works", {
|
|
78
|
+
df <- data.frame(x = 1:5, y = c(2, 4, 3, 5, 4),
|
|
79
|
+
ymin = c(1, 3, 2, 4, 3), ymax = c(3, 5, 4, 6, 5))
|
|
80
|
+
p <- ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) +
|
|
81
|
+
geom_errorbar(width = 0.3) + geom_point()
|
|
82
|
+
expect_output(res <- ggplotcli(p))
|
|
83
|
+
expect_s3_class(res, "Canvas")
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test_that("GeomLinerange works", {
|
|
87
|
+
df <- data.frame(x = 1:5, y = c(2, 4, 3, 5, 4),
|
|
88
|
+
ymin = c(1, 3, 2, 4, 3), ymax = c(3, 5, 4, 6, 5))
|
|
89
|
+
p <- ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) + geom_linerange()
|
|
90
|
+
expect_output(res <- ggplotcli(p))
|
|
91
|
+
expect_s3_class(res, "Canvas")
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test_that("GeomPointrange works", {
|
|
95
|
+
df <- data.frame(x = 1:5, y = c(2, 4, 3, 5, 4),
|
|
96
|
+
ymin = c(1, 3, 2, 4, 3), ymax = c(3, 5, 4, 6, 5))
|
|
97
|
+
p <- ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) + geom_pointrange()
|
|
98
|
+
expect_output(res <- ggplotcli(p))
|
|
99
|
+
expect_s3_class(res, "Canvas")
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test_that("GeomCrossbar works", {
|
|
103
|
+
df <- data.frame(x = 1:5, y = c(2, 4, 3, 5, 4),
|
|
104
|
+
ymin = c(1, 3, 2, 4, 3), ymax = c(3, 5, 4, 6, 5))
|
|
105
|
+
p <- ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) +
|
|
106
|
+
geom_crossbar(fill = "lightblue")
|
|
107
|
+
expect_output(res <- ggplotcli(p))
|
|
108
|
+
expect_s3_class(res, "Canvas")
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test_that("GeomRug works", {
|
|
112
|
+
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rug()
|
|
113
|
+
expect_output(res <- ggplotcli(p))
|
|
114
|
+
expect_s3_class(res, "Canvas")
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test_that("GeomLabel works", {
|
|
118
|
+
df <- data.frame(x = c(1, 2, 3), y = c(3, 1, 2), lab = c("A", "B", "C"))
|
|
119
|
+
p <- ggplot(df, aes(x, y, label = lab)) + geom_label()
|
|
120
|
+
expect_output(res <- ggplotcli(p))
|
|
121
|
+
expect_s3_class(res, "Canvas")
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test_that("GeomRaster works", {
|
|
125
|
+
df <- expand.grid(x = 1:10, y = 1:10)
|
|
126
|
+
df$z <- runif(100)
|
|
127
|
+
p <- ggplot(df, aes(x, y, fill = z)) + geom_raster()
|
|
128
|
+
expect_output(res <- ggplotcli(p))
|
|
129
|
+
expect_s3_class(res, "Canvas")
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test_that("GeomViolin works", {
|
|
133
|
+
p <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_violin()
|
|
134
|
+
expect_output(res <- ggplotcli(p))
|
|
135
|
+
expect_s3_class(res, "Canvas")
|
|
136
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
library(testthat)
|
|
2
|
+
library(plotcli)
|
|
3
|
+
|
|
4
|
+
test_that("plotcli_density works", {
|
|
5
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
6
|
+
expect_silent(plotcli_density(sample_data, color = "blue", braille = TRUE))
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test_that("plotcli_histogram works", {
|
|
10
|
+
sample_data <- rnorm(1000, mean = 5, sd = 2)
|
|
11
|
+
expect_silent(plotcli_histogram(sample_data, color = "yellow"))
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test_that("plotcli_scatter works", {
|
|
15
|
+
expect_silent(plotcli_scatter(x = iris$Sepal.Width, y = iris$Sepal.Length, color = "magenta", braille = FALSE))
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test_that("plotcli_line works", {
|
|
19
|
+
x <- seq(0, 2*pi, length.out = 50)
|
|
20
|
+
y <- sin(x)
|
|
21
|
+
expect_silent(plotcli_line(x = x, y = cos(y), color = "green"))
|
|
22
|
+
expect_silent(plotcli_line(x = x, y = x, color = "magenta", braille = FALSE))
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test_that("plotcli R6 class works", {
|
|
26
|
+
plot_width = 80
|
|
27
|
+
plot_height = 40
|
|
28
|
+
x <- seq(0, 2 * pi, length.out = 100)
|
|
29
|
+
y1 <- sin(x)
|
|
30
|
+
y2 <- cos(x)
|
|
31
|
+
|
|
32
|
+
data_1 = list(x = x, y = y1, name = "y1 = sin(x)", color = "blue", type = "line", braille = FALSE)
|
|
33
|
+
data_2 = list(x = x, y = y2, name = "y2 = cos(x)", color = "red", type = "line", braille = FALSE)
|
|
34
|
+
|
|
35
|
+
plot <- plotcli$new(plot_width = plot_width, plot_height = plot_height, x_label = "X-axis", y_label = "Y-axis")
|
|
36
|
+
expect_silent(plot$add_data(data_1))
|
|
37
|
+
expect_silent(plot$add_data(data_2))
|
|
38
|
+
expect_output(plot$print_plot())
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test_that("constant y-values do not error", {
|
|
42
|
+
x <- seq(0, 10, length.out = 50)
|
|
43
|
+
y <- rep(1.0, length(x))
|
|
44
|
+
expect_output(plotcli_line(x = x, y = y)$print_plot())
|
|
45
|
+
expect_output(plotcli_line(x = x, y = y, braille = TRUE)$print_plot())
|
|
46
|
+
expect_silent(plotcli_scatter(x = x, y = y))
|
|
47
|
+
expect_silent(plotcli_scatter(x = x, y = y, braille = TRUE))
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test_that("constant x-values do not error", {
|
|
51
|
+
x <- rep(5, 50)
|
|
52
|
+
y <- seq(0, 10, length.out = 50)
|
|
53
|
+
expect_output(plotcli_line(x = x, y = y)$print_plot())
|
|
54
|
+
expect_silent(plotcli_scatter(x = x, y = y))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test_that("constant x and y values do not error", {
|
|
58
|
+
x <- rep(3, 50)
|
|
59
|
+
y <- rep(7, 50)
|
|
60
|
+
expect_output(plotcli_line(x = x, y = y)$print_plot())
|
|
61
|
+
expect_silent(plotcli_scatter(x = x, y = y))
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test_that("constant zero values do not error", {
|
|
65
|
+
x <- seq(0, 10, length.out = 50)
|
|
66
|
+
y <- rep(0, length(x))
|
|
67
|
+
expect_output(plotcli_line(x = x, y = y)$print_plot())
|
|
68
|
+
expect_silent(plotcli_scatter(x = x, y = y))
|
|
69
|
+
})
|