Visualization is a central part of any data analysis pipeline. Ideally, you want to visualize data before and after all operations, if possible. Depending on the kind and amount of data you are working on, this can range from straightforward to rather challening, but it’s always worthwhile! rtemis provides functions for static graphics - the mplot3 family of functions - as well as interactive graphics - the dplot3 family. The next two chapters cover static and interactive graphics, respectively. First, let’s look at the available color palettes and themes available to both sets of tools.
Color palettes
rtemis includes a number of builtin color palettes, along with a few functions to create, manipulate, and preview colors.
Shown here with the darkgrayigrid theme, the default rtemis pallette is slightly pastel/desaturated and tries to provide good contrast between groups:
mplot3_x(iris)
Let’s try a different, rather recognizable, palette:
mplot3_x(iris, palette ="google")
Themes
The mplot3 and dplot3 families of functions support multiple different themes:
white
whitegrid
whiteigrid
black
blackgrid
blackigrid
darkgray
darkgraygrid
darkgrayigrid
lightgraygrid
mediumgraygrid
set.seed =2019x <-rnorm(200)y <- x^3+12+rnorm(200)mplot3_xy(x, y, theme ='white', fit ='gam')
mplot3_xy(x, y, theme ='whitegrid', fit ='gam')
mplot3_xy(x, y, theme ='whiteigrid', fit ='gam')
mplot3_xy(x, y, theme ='black', fit ='gam')
mplot3_xy(x, y, theme ='blackgrid', fit ='gam')
mplot3_xy(x, y, theme ='blackigrid', fit ='gam')
mplot3_xy(x, y, theme ='darkgray', fit ='gam')
mplot3_xy(x, y, theme ='darkgraygrid', fit ='gam')
mplot3_xy(x, y, theme ='darkgrayigrid', fit ='gam')
mplot3_xy(x, y, theme ='lightgraygrid', fit ='gam')
mplot3_xy(x, y, theme ='mediumgraygrid', fit ='gam')
System Defaults
You can optionally set system defaults by running the following lines in R or adding them to your .Rprofile file, which is usually found in your home directory. For example, to default to the “darkgrayigrid” theme (works well with a dark VS Code or RStudio theme), you can use the following:
The first line sets the theme for all mplot3/dplot3 functions that support it, and the second line defines the default palette, which works with both light and dark themes.