The goal of plotjs is provide to a base ‘graphics’-like interface to the
Chart.js JavaScript charting library. The main
plotjs() function is an S3 generic like the base plot() function
with methods for various base R objects.
Besides htmlwidgets, it has minimal R dependencies. Tidyverse not
required!
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("arkraieski/plotjs")Here’s some example code for a basic scatter plot using R’s airquality
dataset:
library(plotjs)
air <- airquality
plotjs(air$Ozone, air$Solar.R,
main = "New York Air Quality Measurements",
xlab = "Ozone (ppb)",
ylab = "Solar Radiation (lang)",
col = "red")To see a list of S3 methods:
library(plotjs)
methods(plotjs)
#> [1] plotjs.default* plotjs.density* plotjs.factor* plotjs.function*
#> [5] plotjs.lm*
#> see '?methods' for accessing help and source codeMore are on the way! The goal is to replicate the behavior of base R
plot() methods as closely as possible while also getting the benefits
of using a Chart.js-backed interactive widget. Each method has its own help page that
can be accessed for additional information.
The package is tested on Windows, Linux, and MacOS.