Title: | Command Line Interface Plotting |
---|---|
Description: | The 'plotcli' package provides terminal-based plotting in R. It supports colored scatter plots, line plots, bar plots, and box plots. The package allows users to customize plot appearance, add titles, labels, ticks, and legends, and output the plot as a text-based visualization. |
Authors: | Claas Heuer [aut, cre] |
Maintainer: | Claas Heuer <[email protected]> |
License: | LGPL-3 |
Version: | 0.1.0 |
Built: | 2025-02-15 04:40:09 UTC |
Source: | https://github.com/cheuerde/plotcli |
This function overloads the "+" operator to merge two plotcli objects.
## S3 method for class 'plotcli' plot1 + plot2
## S3 method for class 'plotcli' plot1 + plot2
plot1 |
A plotcli object to be merged. |
plot2 |
A plotcli object to be merged. |
A new plotcli object containing the combined data from both objects.
This function generates a list of points that form a line between two given points using Bresenham's line algorithm.
bresenham(x0, y0, x1, y1)
bresenham(x0, y0, x1, y1)
x0 |
The x-coordinate of the starting point. |
y0 |
The y-coordinate of the starting point. |
x1 |
The x-coordinate of the ending point. |
y1 |
The y-coordinate of the ending point. |
A list of points that form a line between the two given points.
bresenham(0, 0, 5, 5) bresenham(0, 0, -5, -5)
bresenham(0, 0, 5, 5) bresenham(0, 0, -5, -5)
This function prints a plot matrix to the console.
cat_plot_matrix(plot_matrix)
cat_plot_matrix(plot_matrix)
plot_matrix |
The plot matrix to be printed. |
cat_plot_matrix(matrix(c("a", "b", "c", "d"), nrow = 2, ncol = 2))
cat_plot_matrix(matrix(c("a", "b", "c", "d"), nrow = 2, ncol = 2))
This function combines multiple plot matrices horizontally, centering them vertically.
cbind_plots(...)
cbind_plots(...)
... |
A list of plot matrices to be combined. |
A combined plot matrix.
Generic function for combining plotcli objects horizontally
## S3 method for class 'plotcli' cbind(..., deparse.level = 1)
## S3 method for class 'plotcli' cbind(..., deparse.level = 1)
... |
plotcli objects to be combined. |
deparse.level |
The deparsing level for the arguments. |
A combined plot matrix.
This function formats a number to a string of exactly four characters.
format_four_chars(num)
format_four_chars(num)
num |
The number to be formatted. |
A string representation of the number with exactly four characters.
format_four_chars(123) format_four_chars(-12.34)
format_four_chars(123) format_four_chars(-12.34)
This function returns a subset of the data for a specific geom.
get_data_subset(geom_name, data, aes, p_build)
get_data_subset(geom_name, data, aes, p_build)
geom_name |
The name of the geom for which the data subset is needed. |
data |
The data to be subsetted. |
aes |
The aesthetic mappings for the geom. |
p_build |
The ggplot build object. |
A list containing the data subset for the specified geom.
This function returns a vector of terminal colors.
get_term_colors(n = NULL)
get_term_colors(n = NULL)
n |
The number of colors to return. |
A vector of terminal colors.
get_term_colors(5) get_term_colors(10)
get_term_colors(5) get_term_colors(10)
This function takes a ggplot object and renders it in the terminal using ASCII or Braille characters.
ggplotcli(ggplot_obj, plot_width = 80, plot_height = 40, braille = TRUE)
ggplotcli(ggplot_obj, plot_width = 80, plot_height = 40, braille = TRUE)
ggplot_obj |
A ggplot object to be rendered in the terminal. |
plot_width |
Width of the terminal plot in characters (default: 80). |
plot_height |
Height of the terminal plot in characters (default: 40). |
braille |
Use Braille characters for higher resolution (default: TRUE). |
A TerminalPlot object.
This function checks if a given character is a Braille character.
is_braille(char)
is_braille(char)
char |
The character to be checked. |
A boolean value indicating whether the character is a Braille character or not.
is_braille("A")
is_braille("A")
This function applies a specified color to a given text string.
make_colored(x, color = NULL)
make_colored(x, color = NULL)
x |
The text string to be colored. |
color |
The color to be applied to the text. If NULL, the color codes will be removed. |
A colored text string or a text string with color codes removed.
make_colored("Hello, world!", "blue") make_colored("Hello, world!", NULL)
make_colored("Hello, world!", "blue") make_colored("Hello, world!", NULL)
This function takes a vector of names and ensures that each name is unique by appending a number if necessary.
make_unique_names(names)
make_unique_names(names)
names |
A character vector of names. |
A character vector of unique names.
make_unique_names(c("apple", "apple", "banana", "apple"))
make_unique_names(c("apple", "apple", "banana", "apple"))
This function normalizes the given data to a specified plot range.
normalize_data(data, data_min, data_max, plot_range)
normalize_data(data, data_min, data_max, plot_range)
data |
The data to be normalized. |
data_min |
The minimum value of the data. |
data_max |
The maximum value of the data. |
plot_range |
The range to normalize the data to. |
The normalized data.
normalize_data(c(1, 2, 3, 4, 5), 1, 5, 10) normalize_data(c(10, 20, 30, 40, 50), 10, 50, 100)
normalize_data(c(1, 2, 3, 4, 5), 1, 5, 10) normalize_data(c(10, 20, 30, 40, 50), 10, 50, 100)
Short version of plotcli_bar function.
pclib( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "barplot", ... )
pclib( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "barplot", ... )
y |
A numeric vector of values |
x |
A vector of categories |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "barplot") |
... |
Additional arguments passed to the plotcli$new() function |
x <- 1:5 y <- c(10, 15, 8, 12, 6) pclib(x, y)
x <- 1:5 y <- c(10, 15, 8, 12, 6) pclib(x, y)
Short version of plotcli_box function.
pclibx( y, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "boxplot", ... )
pclibx( y, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "boxplot", ... )
y |
A list of numeric vectors of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "boxplot") |
... |
Additional arguments passed to the plotcli$new() function |
x |
A vector of categories |
y <- rnorm(50, mean = 0) pclib(y)
y <- rnorm(50, mean = 0) pclib(y)
Short version of plotcli_density function.
pclid( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Density", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "density", ... )
pclid( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Density", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "density", ... )
x |
A numeric vector of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "Density") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "density") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) pclid(x)
x <- rnorm(100) pclid(x)
Short version of plotcli_histogram function.
pclih( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Frequency", color = NULL, braille = getOption("plotcli.braille", TRUE), bin_width = NULL, ylim = NULL, name = "histogram", ... )
pclih( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Frequency", color = NULL, braille = getOption("plotcli.braille", TRUE), bin_width = NULL, ylim = NULL, name = "histogram", ... )
x |
A numeric vector of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "Frequency") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
bin_width |
Width of the bins (default: NULL) |
ylim |
y limits (default: NULL) |
name |
Name of the plot element (default: "histogram") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) pclih(x)
x <- rnorm(100) pclih(x)
Short version of plotcli_line function.
pclil( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "line", ... )
pclil( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "line", ... )
y |
A numeric vector of y values |
x |
A numeric vector of x values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "line") |
... |
Additional arguments passed to the plotcli$new() function |
x <- 1:10 y <- x^2 pclil(x, y)
x <- 1:10 y <- x^2 pclil(x, y)
Short version of plotcli_scatter function.
pclis( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "scatter", ... )
pclis( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "scatter", ... )
y |
A numeric vector of y values |
x |
A numeric vector of x values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "scatter") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) y <- rnorm(100) pclis(x, y)
x <- rnorm(100) y <- rnorm(100) pclis(x, y)
plotcli R6 Class
plotcli R6 Class
This class provides a set of methods to create and customize command-line plots using R6. It supports various plot types, such as scatter, line, bar, and box plots, and allows customization of plot elements, such as title, axis labels, ticks, and legend.
plotcli <- plotcli$new() plotcli$add_data(data) plotcli$print_plot()
Initializes the PlotCLI object with parameters.
Initializes the plot matrix with the plot canvas.
Default print method for PlotCLI object.
Adds a single row to the plot matrix.
Adds a single column to the plot matrix.
Adds borders around the plot canvas.
Adds row and column index to the plot matrix.
Adds a title to the plot matrix.
Adds y-axis tick labels to the plot matrix.
Adds a y-axis label to the plot matrix.
Adds x-axis tick labels to the plot matrix.
Adds an x-axis label to the plot matrix.
Adds a legend to the plot matrix.
Adds data to the object.
Gets minimum and maximum values for x and y.
Removes out of range data points if xlim and ylim were given.
Draws a scatter plot on the plot canvas.
Draws a line plot on the plot canvas.
Draws a bar plot on the plot canvas.
Draws a bar plot with braille characters on the plot canvas.
Draws a box plot on the plot canvas.
Assembles all plot elements and prints the plot to the console.
plot_width
The width of the plot
plot_height
The height of the plot
plot_canvas
The canvas for drawing the plot
plot_matrix
The matrix containing the entire plot, including borders, labels, and title
data
A list containing the data sets to be plotted
title
The title of the plot
x_label
The label for the x-axis
y_label
The label for the y-axis
ylim
The limits for the y-axis
xlim
The limits for the x-axis
x_min
The minimum value of the x-axis
x_max
The maximum value of the x-axis
y_min
The minimum value of the y-axis
y_max
The maximum value of the y-axis
plot_matrix_canvas_row_start
The starting row of the plot canvas within the plot matrix
plot_matrix_canvas_col_start
The starting column of the plot canvas within the plot matrix
is_boxplot
A logical value indicating if the plot is a boxplot
draw_legend
A logical value indicating if the legend should be drawn
new()
Initialize object
plotcli$new( plot_width = 60, plot_height = 20, x_label = "x", y_label = "y", ylim = NULL, xlim = NULL, title = NULL, is_boxplot = FALSE, draw_legend = TRUE )
plot_width
integer, width of the plot canvas
plot_height
integer, height of the plot canvas
x_label
character, label for the x-axis
y_label
character, label for the y-axis
ylim
numeric vector, limits for the y-axis
xlim
numeric vector, limits for the x-axis
title
character, title of the plot
is_boxplot
logical, whether the plot is a boxplot
draw_legend
logical, whether to draw the legend This function initializes the plot matrix based on the plot canvas.
initialize_plot_matrix()
Initialize the plot matrix
plotcli$initialize_plot_matrix()
plot_width
The width of the plot
plot_height
The height of the plot
A plot matrix object
print()
Default print method for plotcli object
plotcli$print(...)
...
Additional arguments passed to the print method
The plotcli object, invisibly
add_row()
Add a single row to the plot matrix
plotcli$add_row(bottom = FALSE)
bottom
logical, if TRUE, add row to the bottom of the matrix, otherwise add to the top (default: FALSE)
add_col()
Add a single column to the plot matrix
plotcli$add_col()
add_borders()
Add borders to the plot matrix
plotcli$add_borders()
add_row_col_index()
Add row and column index to the plot matrix Add title to the plot matrix
plotcli$add_row_col_index()
add_title()
plotcli$add_title()
title
character, title of the plot Add y-ticks label to the plot matrix
add_y_ticks()
plotcli$add_y_ticks(n_ticks = 5)
n_ticks
numeric, number of ticks Add y-axis label to the plot matrix
add_y_label()
Add a y-axis label to the plot matrix
plotcli$add_y_label(y_label = self$y_label)
y_label
character, the y-axis label to be added Add x-ticks label to the plot matrix
add_x_ticks()
plotcli$add_x_ticks(n_ticks = 5)
n_ticks
numeric, number of ticks Add x-axis label to the plot matrix
add_x_label()
Add x-axis label to the plot matrix
plotcli$add_x_label(x_label = self$x_label)
x_label
x label Add legend to the plot matrix
add_legend()
Add legend to the plot matrix Add data to the object.
plotcli$add_legend()
add_data()
plotcli$add_data(data)
data
list, list with elements: x, y, type, color, braille, name Get minimum and maximum values for x and y
get_min_max()
Calculate the minimum and maximum values for x and y Function to remove out of range data points if xlim and ylim were given
plotcli$get_min_max()
remove_out_of_range_data()
Remove data points that are outside the specified xlim and ylim Draw a scatter plot to the plot canvas.
plotcli$remove_out_of_range_data()
draw_scatter_plot()
Draw a scatter plot of the specified data set on the plot canvas.
plotcli$draw_scatter_plot(set_idx)
set_idx
numeric, the data element index to be drawn Draw a line plot to the plot canvas.
draw_line_plot()
plotcli$draw_line_plot(set_idx)
set_idx
numeric, the data element index to be drawn Draw a barplot to the plot canvas.
draw_barplot()
plotcli$draw_barplot(set_idx)
set_idx
numeric, the data element index to be drawn Draw a barplot to the plot canvas with braille characters.
draw_barplot_braille()
plotcli$draw_barplot_braille(set_idx)
set_idx
numeric, the data element index to be drawn Draw a boxplot to the plot canvas.
draw_boxplot()
plotcli$draw_boxplot(set_idx)
set_idx
numeric, the data element index to be drawn Draw colors to the canvas
draw_colors()
In the draw_ functions we have been keeping track of the locations of the colored matrix elements. These are now being colored. Draw the different plots types from all data elements to the canvas
plotcli$draw_colors()
draw_plot()
This function iterates through all data elements and calls the appropriate draw_ function based on the plot type (scatter, line, boxplot, or barplot). Make plot matrix: assembles all plot elements (canvas + borders + title + axes + legend)
plotcli$draw_plot()
make_plot_matrix()
This function assembles all plot elements (canvas + borders + title + axes + legend) and creates the final plot matrix. Export plot matrix
plotcli$make_plot_matrix()
export_plot_matrix()
This function exports the plot matrix.
plotcli$export_plot_matrix()
The plot matrix. Main plotting function: assembles all plot elements (canvas + borders + title + axes + legend) and prints the plot by 'cat'ing the plot matrix to the console.
print_plot()
This function assembles all plot elements (canvas + borders + title + axes + legend) and prints the final plot by 'cat'ing the plot matrix to the console. Merge two plotcli objects
This method combines the data from two plotcli objects into a single plotcli object. It takes the maximum of the plot_width and plot_height, combines the titles, and sets the xlim and ylim to the minimum and maximum values of both objects.
plotcli$print_plot()
merge()
plotcli$merge(other)
other
A plotcli object to be merged with the current object.
A new plotcli object containing the combined data from both objects.
clone()
The objects of this class are cloneable with this method.
plotcli$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create a new plotcli object plotcli <- plotcli$new() # Add data for a scatter plot plotcli$add_data(list(x = 1:10, y = rnorm(10), type = "scatter", color = "red")) # Print the plot plotcli$print_plot()
# Create a new plotcli object plotcli <- plotcli$new() # Add data for a scatter plot plotcli$add_data(list(x = 1:10, y = rnorm(10), type = "scatter", color = "red")) # Print the plot plotcli$print_plot()
Create a bar plot using plotcli. Short alias: pclb
.
plotcli_bar( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "barplot", ... )
plotcli_bar( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "barplot", ... )
y |
A numeric vector of values |
x |
A vector of categories |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "barplot") |
... |
Additional arguments passed to the plotcli$new() function |
x <- 1:5 y <- c(10, 15, 8, 12, 6) plotcli_bar(x, y)
x <- 1:5 y <- c(10, 15, 8, 12, 6) plotcli_bar(x, y)
Create a box plot using plotcli. Short alias: pclbx
.
plotcli_box( y, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "boxplot", ... )
plotcli_box( y, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "boxplot", ... )
y |
A list of numeric vectors of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "boxplot") |
... |
Additional arguments passed to the plotcli$new() function |
x |
A vector of categories |
y <- rnorm(50, mean = 0) plotcli_box(y)
y <- rnorm(50, mean = 0) plotcli_box(y)
Create a density plot using plotcli. Short alias: pcld
.
plotcli_density( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Density", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "density", ... )
plotcli_density( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Density", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "density", ... )
x |
A numeric vector of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "Density") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "density") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) plotcli_density(x)
x <- rnorm(100) plotcli_density(x)
Create a histogram plot using plotcli. Short alias: pclih
.
plotcli_histogram( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Frequency", color = NULL, braille = getOption("plotcli.braille", TRUE), bin_width = NULL, ylim = NULL, name = "histogram", ... )
plotcli_histogram( x, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "Frequency", color = NULL, braille = getOption("plotcli.braille", TRUE), bin_width = NULL, ylim = NULL, name = "histogram", ... )
x |
A numeric vector of values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "Frequency") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
bin_width |
Width of the bins (default: NULL) |
ylim |
y limits (default: NULL) |
name |
Name of the plot element (default: "histogram") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) plotcli_histogram(x)
x <- rnorm(100) plotcli_histogram(x)
Create a line plot using plotcli. Short alias: pcli
.
plotcli_line( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "line", ... )
plotcli_line( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "line", ... )
y |
A numeric vector of y values |
x |
A numeric vector of x values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "line") |
... |
Additional arguments passed to the plotcli$new() function |
x <- 1:10 y <- x^2 plotcli_line(x, y)
x <- 1:10 y <- x^2 plotcli_line(x, y)
Set global options for plotcli
plotcli_options(plot_width = 60, plot_height = 20, braille = FALSE)
plotcli_options(plot_width = 60, plot_height = 20, braille = FALSE)
plot_width |
Default plot width (default: 60) |
plot_height |
Default plot height (default: 20) |
braille |
Default braille setting (default: FALSE) |
Create a scatter plot using plotcli. Short alias: pclis
.
plotcli_scatter( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "scatter", ... )
plotcli_scatter( y, x = NULL, plot_width = getOption("plotcli.plot_width", 80), plot_height = getOption("plotcli.plot_height", 40), x_label = "x", y_label = "y", color = NULL, braille = getOption("plotcli.braille", TRUE), name = "scatter", ... )
y |
A numeric vector of y values |
x |
A numeric vector of x values |
plot_width |
Width of the plot (default: 80) |
plot_height |
Height of the plot (default: 40) |
x_label |
Label for the x-axis (default: "x") |
y_label |
Label for the y-axis (default: "y") |
color |
Color of the plot elements (default: NULL) |
braille |
Use Braille characters for the plot (default: TRUE) |
name |
Name of the plot element (default: "scatter") |
... |
Additional arguments passed to the plotcli$new() function |
x <- rnorm(100) y <- rnorm(100) plotcli_scatter(x, y)
x <- rnorm(100) y <- rnorm(100) plotcli_scatter(x, y)
This function combines multiple plot matrices vertically, centering them horizontally.
rbind_plots(...)
rbind_plots(...)
... |
A list of plot matrices to be combined. |
A combined plot matrix.
Generic function for combining plotcli objects vertically
## S3 method for class 'plotcli' rbind(..., deparse.level = 1)
## S3 method for class 'plotcli' rbind(..., deparse.level = 1)
... |
plotcli objects to be combined. |
deparse.level |
The deparsing level for the arguments. |
A combined plot matrix.
This function removes ANSI color codes from a given text string.
remove_color_codes(s)
remove_color_codes(s)
s |
The text string containing ANSI color codes. |
A text string with ANSI color codes removed.
colored_text <- make_colored("Hello, world!", "blue") remove_color_codes(colored_text)
colored_text <- make_colored("Hello, world!", "blue") remove_color_codes(colored_text)