knitr::opts_chunk$set(echo = TRUE) library(billboard) library(dplyr)
billboard
comes with countless options, they are not all listed here. This page merely tries to demonstrate what can be achieved with the package.
Add labels and rotate the chart and add a title.
library(dplyr) mtcars %>% mutate(models = rownames(.)) %>% slice(1:5) %>% b_board(models) %>% b_bar(wt) %>% b_rotate() %>% b_labels() %>% b_title("Rotated chart")
Change the legend square size and position. Note that you can name each chart added with name
mtcars %>% mutate(models = rownames(.)) %>% slice(1:5) %>% b_board(models) %>% b_bar(wt, name = "weight") %>% b_bar(drat) %>% b_legend(width = 50, height = 20, position = "inset")
No axis change or legend, change height.
mtcars %>% mutate(x = 1:n()) %>% b_board(x) %>% b_spline(wt) %>% b_xaxis(show = FALSE) %>% b_yaxis(show = FALSE) %>% b_size(height = 50) %>% b_legend(show = FALSE)
Mark lines and regions.
mtcars %>% mutate(x = 1:n()) %>% b_board(x) %>% b_area_spline(drat, name = "Rear axle ratio") %>% b_spline(mpg, axis = "y2") %>% b_grid_line(3, "avg (maybe)", axis = "y") %>% b_region("x", 8, 12)
Customise chart color.
mtcars %>% mutate(x = 1:n()) %>% b_board(x) %>% b_bar(wt) %>% b_area(drat) %>% b_bar(mpg, axis = "y2") %>% b_color_brewer("Accent", 3)
Add a subchart
mtcars %>% mutate(x = 1:n()) %>% b_board(x) %>% b_bar(wt) %>% b_area(drat) %>% b_subchart()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.