How it works
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(ggblanket)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.1
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(stringr)
library(tidyr)
library(palmerpenguins)
library(patchwork)
library(canvasXpress)
set_blanket()
Almost forty gg_* wrapper functions
p <- penguins |>
gg_point(
x = flipper_length_mm,
y = body_mass_g,
)
p
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

canvasXpress(p, width = 672, height = 500)
A single col argument to colour and fill by a variable
p <- penguins |>
gg_point(
x = flipper_length_mm,
y = body_mass_g,
col = species,
)
p
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

canvasXpress(p, width = 672, height = 500)
p <- penguins |>
drop_na(sex) |>
mutate(across(sex, str_to_sentence)) |>
gg_bar(
position = "dodge",
y = species,
col = sex,
width = 0.75,
)
p

canvasXpress(p, width = 672, height = 500)
A facet argument to facet by a variable
p <- penguins |>
drop_na(sex) |>
mutate(across(sex, str_to_sentence)) |>
gg_histogram(
x = flipper_length_mm,
facet = species,
binwidth = 2
)
p

canvasXpress(p, width = 672, height = 500)
A facet2 argument to facet by a 2nd variable
p <- penguins |>
mutate(across(sex, str_to_sentence)) |>
gg_histogram(
x = flipper_length_mm,
facet = species,
facet2 = sex,
binwidth = 2
)
p
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_bin()`).

canvasXpress(p, width = 672, height = 500)
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_bin()`).
Unspecified titles converted to snakecase::sentence_case
p <- diamonds |>
gg_hex(
coord = coord_cartesian(clip = "on"),
x = carat,
y = price,
y_limits = c(0, 20000),
)
## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.
p
