The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
An R-package for graphical output in terminals. Currently supports terminals that support the Terminal Graphics Protocol and terminals that support Sixel. It implements a graphical device that will output into the terminal and also some functions for retrieving information from the terminal such as the colour scheme used, the dimensions of the terminal and function for displaying png images and image matrices.
Set the tgp
(Terminal Graphics Protocol) device as the
standard device and instruct the package to use the terminal colors
(only supported currently in Kitty):
options(device = terminalgraphics::tgp, term_col = TRUE)
For example, one could use the following lines in
~/.Rprofile
to set the the tgp
device as the
default device.
if (interactive() && terminalgraphics::has_tgp_support()) {
options(device = terminalgraphics::tgp, term_col = TRUE)
}
or for Sixel support:
if (interactive() && terminalgraphics::has_tgp_support()) {
options(device = terminalgraphics::sixel)
}
Creating a plot like, for example:
{data(iris)
plot(iris$Sepal.Width, iris$Sepal.Length,
col = term_palette()[iris$Species],
pch = 20)
grid(lty = 2)
legend("topright", legend = levels(iris$Species),
col = term_palette()[1:3], pch = 20)
}
Results in:
By default it will match the colours of the plot to those used of the theme used in the terminal (currently the theme can only be determined for Kitty).
Other functions are:
png2terminal
, png2tgp
,
png2sixel
raster2terminal
, raster2tgp
,
raster2sixel
term_dim
, term_width
,
term_height
term_palette
kitty_foreground
and kitty_background
has_tgp_support
has_sixel_support
is_kitty
Every time the contents of the graphics device change after evaluating an expression, a new version of the plot is shown in the terminal. Therefore, the following two lines will result in two plots in the terminal:
plot(rnorm(200))
abline(h = 0)
If you want only one plot to appear in the terminal, you should combine the lines into one expression:
{ plot(rnorm(200))
abline(h = 0)
}
The size and resolution of the plot can be changed using arguments of
tgp
and sixel
:
tgp(width = 1000, height = 500)
plot(rnorm(200))
It is also possible to set some of these using options:
options(device = terminalgraphics::tgp, term_width = 1000, term_height = 500,
term_res = 150, term_col = TRUE)
Note that these options are used for new devices. Therefore,
when there is already a device open, you should call
tgp
/sixel
to open a new device or close open
devices using dev.off
before starting a new plot.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.