knitr::opts_chunk$set( echo = T, message = F, warning = F, error = F, collapse = TRUE, comment = NA, #R.options=list(width=220), # code dev.args = list(bg = 'transparent'), dev = 'png', # viz fig.path = "man/figures/README-", fig.align = 'center', out.width = '75%', fig.asp = .75, cache.rebuild = F, cache = F ) # cache
Visibly is a handful of functions I use for color palettes, themes, etc. in R. Inside you will find:
colortools::complementary
colortools::adjacent
etc. Install the development version directly from GitHub:
# install.packages("devtools") devtools::install_github("m-clark/visibly")
Visibly is currently in its early stages, so more may be added soon. For some additional palettes for those fond of another time, you might be interested in NineteenEightyR.
Create a palette from a single starting point. This requires the colortools package to create equally spaced colors.
library(visibly) create_palette('papayawhip')
Plot it to get a feel for things.
create_palette('#ff5500', plot = T)
One of the built-in palettes is based on R's blue. Others are based on Stan's red, plotly's base colors, and the red-blue palette from RColorBrewer.
A clean theme for plotly.
library(plotly) mtcars %>% plot_ly(x=~wt, y=~mpg, color=~cyl) %>% add_markers(marker=list(size=15)) %>% theme_plotly()
Visualize a correlation matrix via factor analysis.
data('bfi', package = 'visibly') cor_matrix = cor(bfi, use='pair') corr_heat(cor_matrix)
Plot some model coefficients. Requires the scico package.
fit_lm = lm(mpg ~ ., mtcars) plot_coefficients(fit_lm)
Plot GAM results
library(mgcv) d = gamSim() gam_model = gam(y ~ x0 + s(x1) + s(x2, bs='gp') + s(x3, bs='ps'), data=d) plot_gam(gam_model, main_var = x2) plot_gam_check(gam_model)
See the intro for more.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.