Load data and Libraries

https://r4ds.had.co.nz/data-visualisation.html

if (!("ggplot2" %in% installed.packages())) {
    install.packages('ggplot2')
}
library('ggplot2')
if (!("ggthemes" %in% installed.packages())) {
    install.packages('ggthemes')
}
library('ggthemes')
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')

Example Plot

mtcars2 <- within(mtcars, {
  vs <- factor(vs, labels = c("V-shaped", "Straight"))
  am <- factor(am, labels = c("Automatic", "Manual"))
  cyl  <- factor(cyl)
  gear <- factor(gear)
})

p <- ggplot(mtcars2) +
     geom_point(aes(x = wt, y = mpg, colour = gear)) +
     labs(
       title = "Fuel economy declines as weight increases",
       subtitle = "(1973-74)",
       caption = "Data from the 1974 Motor Trend US magazine.",
       x = "Weight (1000 lbs)",
       y = "Fuel economy (mpg)",
       colour = "Gears"
     )

Default

p

canvasXpress(p, width = 672, height = 500)

Economist

pe <- p + theme_economist() + scale_colour_economist()
pe

canvasXpress(pe, width = 672, height = 500)

Excel

pe <- p + theme_excel() + scale_colour_excel()
pe

canvasXpress(pe, width = 672, height = 500)

igray

pi <- p + theme_igray()
pi

canvasXpress(pi, width = 672, height = 500)

Solarized

ps <- p + theme_solarized() + scale_colour_solarized()
ps

canvasXpress(ps, width = 672, height = 500)

Solarized ligth FALSE

ps <- p + theme_solarized(light = FALSE) + scale_colour_solarized()
ps

canvasXpress(ps, width = 672, height = 500)

Tufte

pt <- p + theme_tufte()
pt

canvasXpress(pt, width = 672, height = 500)

Color blind

cb <- p + scale_color_colorblind()
cb