Load data and Libraries
if (!("ggplot2" %in% installed.packages())) {
install.packages('ggplot2')
}
library('ggplot2')
if (!("tidyverse" %in% installed.packages())) {
install.packages('tidyverse')
}
library('tidyverse')
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
if (!("dplyr" %in% installed.packages())) {
install.packages('dplyr')
}
library('dplyr')
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')
Creating a ggplot
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy))
g

canvasXpress(g, width = 672, height = 500)
Aesthetic mappings - Color
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class))
g

canvasXpress(g, width = 672, height = 500)
Size
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, size = class))
g
## Warning: Using size for a discrete variable is not advised.

canvasXpress(g, width = 672, height = 500)
## Warning: Using size for a discrete variable is not advised.
Alpha
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, alpha = class))
g
## Warning: Using alpha for a discrete variable is not advised.

canvasXpress(g, width = 672, height = 500)
## Warning: Using alpha for a discrete variable is not advised.
Shape
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, shape = class))
g
## Warning: The shape palette can deal with a maximum of 6 discrete values because more
## than 6 becomes difficult to discriminate
## ℹ you have requested 7 values. Consider specifying shapes manually if you need
## that many have them.
## Warning: Removed 62 rows containing missing values or values outside the scale range
## (`geom_point()`).

canvasXpress(g, width = 672, height = 500)
## Warning: The shape palette can deal with a maximum of 6 discrete values because more
## than 6 becomes difficult to discriminate
## ℹ you have requested 7 values. Consider specifying shapes manually if you need
## that many have them.
Facets - wrap
g = ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy)) + facet_wrap(~ class, nrow = 2)
g
