knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(g2r)
The adjust
function is used to nudge data. It is often necessary when using fig_interval
grouped by color
.
df <- data.frame( x = rep(letters, 3), y = runif(78), grp = rep(c("A", "B", "C"), each = 26) ) g2(df, asp(x, y, color = "grp")) %>% fig_interval()
The above is wrong as bars are overlapping.
g2(df, asp(x, y, color = "grp")) %>% fig_interval(adjust("dodge"))
g2(df, asp(x, y, color = "grp")) %>% fig_interval(adjust("stack"))
Note you can use multiple adjust
in the same figure.
g2(df, asp(x, y, color = "grp")) %>% fig_interval(adjust("stack"), adjust("symmetric"))
g2(cars, asp(dist, speed)) %>% fig_point(asp(shape = "circle")) %>% fig_point(adjust("jitter"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.