if (!("ggplot2" %in% installed.packages())) {
install.packages('ggplot2')
}
library('ggplot2')
## Warning: package 'ggplot2' was built under R version 4.4.1
if (!("devtools" %in% installed.packages())) {
install.packages('devtools')
}
if (!("canvasXpress" %in% installed.packages())) {
devtools::install_github('neuhausi/canvasXpress')
}
#devtools::install_local("~/git/canvas/R/canvasXpress.tar.gz", build_manual = TRUE, upgrade = "always")
library('canvasXpress')
This demo shows the ability to create facets with CanvasXpress through ggplot.
w <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_wrap(~class, ncol = 3)
w
canvasXpress(w)
g <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_grid(. ~cyl)
g
canvasXpress(g)
g2 <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_grid(drv ~ .)
g2
canvasXpress(g2)
g3 <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_grid(drv ~ cyl)
g3
canvasXpress(g3)
mean_wt <- data.frame(cyl = c(4, 6, 8), wt = c(2.28, 3.11, 4.00))
g4 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_wrap(~ cyl) + geom_hline(aes(yintercept = wt), mean_wt)
g4
canvasXpress(g4)
###ggplot
mean_wt <- data.frame(cyl = c(4, 6, 8), wt = c(2.28, 3.11, 4.00))
g5 <- ggplot(mtcars, aes(mpg, wt, colour = wt)) + geom_point() + geom_hline(aes(yintercept = wt, colour = wt), mean_wt) + facet_wrap(~ cyl)
g5
canvasXpress(g5)
sessionInfo()
## R version 4.4.0 (2024-04-24)
## Platform: aarch64-apple-darwin20
## Running under: macOS 15.5
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] canvasXpress_1.50.5 ggplot2_3.5.2
##
## loaded via a namespace (and not attached):
## [1] vctrs_0.6.5 cli_3.6.5 knitr_1.50 rlang_1.1.6
## [5] xfun_0.52 generics_0.1.4 jsonlite_2.0.0 labeling_0.4.3
## [9] glue_1.8.0 htmltools_0.5.8.1 sass_0.4.10 scales_1.4.0
## [13] rmarkdown_2.29 grid_4.4.0 evaluate_1.0.4 jquerylib_0.1.4
## [17] tibble_3.3.0 fastmap_1.2.0 yaml_2.3.10 lifecycle_1.0.4
## [21] compiler_4.4.0 dplyr_1.1.4 RColorBrewer_1.1-3 htmlwidgets_1.6.4
## [25] pkgconfig_2.0.3 rstudioapi_0.16.0 farver_2.1.2 digest_0.6.37
## [29] R6_2.6.1 tidyselect_1.2.1 pillar_1.10.2 magrittr_2.0.3
## [33] bslib_0.9.0 withr_3.0.2 tools_4.4.0 gtable_0.3.6
## [37] cachem_1.1.0