## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5 ) ## ----setup-------------------------------------------------------------------- library(glyph) ## ----------------------------------------------------------------------------- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) |> interact(tooltip = TRUE, hover = "enlarge") |> titles(title = "Motor Trend Cars") |> render() ## ----------------------------------------------------------------------------- glyph(mtcars, x = cyl, y = mpg) |> mark_bar() |> animate(transition = "slide", stagger = 50) |> render() ## ----------------------------------------------------------------------------- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) |> interact(tooltip = TRUE) |> theme_tokens(preset = "dark") |> titles(title = "Dark Theme Example") |> render() ## ----------------------------------------------------------------------------- mtcars_named <- data.frame(model = rownames(mtcars), mtcars, row.names = NULL) glyph(mtcars_named, x = wt, y = mpg) |> mark_point(color = cyl) |> mark_text(label = model, smart_repel = TRUE) |> render() ## ----------------------------------------------------------------------------- p1 <- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) |> interact(brush = TRUE) p2 <- glyph(mtcars, x = hp, y = mpg) |> mark_point(color = cyl) |> interact(brush = TRUE) compose(p1, p2, type = "hstack", linked_selections = TRUE) |> render() ## ----------------------------------------------------------------------------- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) |> facet(cols = cyl) |> render() ## ----------------------------------------------------------------------------- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) |> marginals(x = "histogram", y = "density") |> render() ## ----------------------------------------------------------------------------- main_plot <- glyph(mtcars, x = wt, y = mpg) |> mark_point(color = cyl) detail_plot <- glyph(mtcars, x = cyl, y = mpg) |> mark_bar() inset(main_plot, detail_plot, position = "top-right") |> render() ## ----------------------------------------------------------------------------- glyph(mtcars, x = wt, y = mpg) |> mark_point(size = hp, color = cyl) |> animate(by = gear, transition = "morph", duration = 800) |> render()