knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(ggplot2) library(rxtheme) library(trendyy) library(tidyverse) # get some google trend data q <- c("Natuurmonumenten", "Wereld Natuur Fonds") q_trends <- trendy(q, from = "2019-01-01", to = Sys.Date())
The package is aimed at making it easy to produce RevelX styled content to be used in PowerPoint.
# visualize data with all defaults q_trends %>% get_interest() %>% ggplot(aes(date, hits, color = keyword)) + geom_line() + geom_point(alpha = .5) + theme_rx( base_family = "Ubuntu", grid_lines = "#eeeeee")+ # apply scale_color_rx( palette = "natuurmonumenten" , reverse = T)+ scale_fill_rx( palette = "natuurmonumenten" , reverse = T)+ theme(legend.position = "top") + labs(x = "Time", y = "Relative Search Popularity", title = "")
RevelX has a number of predefined palletes. Default "main" uses RevelX theme colors as outlined in the brand guidelines. You can also reverse the color palette by calling reverse = TRUE
.
You can see the available palettes by calling show_palette
.
# show palette show_palette() # create bar chart q_trends %>% get_interest() %>% ggplot(aes(date, hits, color = keyword)) + geom_line( ) + theme_rx( background_color = "transparent" , grid_lines = "#eeeeee", base_family = "Ubuntu") + # apply scale_color_rx( palette = "natuurmonumenten", reverse = F)+ facet_grid(.~keyword)+ labs( x = "Time", y = "Relative Search Popularity", title = "") save_rx( plot = t, type = "wide", file_name = "slide_three.png", dpi = "print" )
For continous variables you can set a color scheme based on the palette of choice.
# using a different predefined pallete ggplot(faithfuld, aes(waiting, eruptions, fill = density)) + geom_tile() + theme_rx()+ scale_fill_rx( palette = "natuurmonumenten", discrete = F, reverse = F)
For convenience the save_rx function saves the output in a PowerPoint ready format. the save_rx
function is a wrapper for ggsave
and thus supports most features.
The first argument is the ggplot itself, so it's better to use all the argument names when calling the function. You can pass a ggplot object to the save_rx function so you can automate
save_rx( type = "wide",
file_name = "slide.png",
dpi = "screen")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.