4 Visualization

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.

4.1 Color palettes

rtemis includes a number of builtin color palettes, along with a few functions to create, manipulate, and preview colors.

[2020-06-23 08:17:47 rtPalette] The following palettes are available: 
 [1] "pennCol"       "imperialCol"   "stanfordCol"   "ucsfCol"      
 [5] "ucdCol"        "berkeleyCol"   "ucscCol"       "ucmercedCol"  
 [9] "ucsbCol"       "uclaCol"       "ucrColor"      "uciCol"       
[13] "ucsdCol"       "californiaCol" "caltechCol"    "cmuCol"       
[17] "princetonCol"  "columbiaCol"   "yaleCol"       "brownCol"     
[21] "cornellCol"    "hmsCol"        "dartmouthCol"  "usfCol"       
[25] "uwCol"         "jhuCol"        "nyuCol"        "chicagoCol"   
[29] "pennstateCol"  "texasCol"      "techCol"       "jeffersonCol" 
[33] "hawaiiCol"     "nihCol"        "torontoCol"    "mcgillCol"    
[37] "uclCol"        "oxfordCol"     "nhsCol"        "ethCol"       
[41] "rwthCol"       "firefoxCol"    "mozillaCol"    "appleCol"     
[45] "googleCol"     "amazonCol"     "microsoftCol"  "rtCol"        
[49] "rtCol1"        "rtCol2"        "rtCol3"        "grays"        

Let’s use the previewcolor function to look at a selection of the available palettes:

previewcolor(imperialCol, "Imperial")

previewcolor(ucsfCol, "UCSF")

previewcolor(pennCol, "Penn")

previewcolor(stanfordCol, "Stanford")

previewcolor(berkeleyCol, "Berkeley")

previewcolor(uclaCol, "UCLA")

previewcolor(ucsdCol, "UC San Diego")

previewcolor(cmuCol, "Carnegie Mellon")

previewcolor(firefoxCol, "Firefox")

Shown here with the darkgrid theme, the default rtemis pallette is slightly pastel/desaturated and tries to provide good contrast between groups:


Let’s try a different, rather recognizable, palette:

mplot3.x(iris, palette = "google")

4.2 Themes

The mplot3 and dplot3 families of functions support different themes:

  • white
  • whitegrid
  • lightgrid
  • black
  • blackgrid
  • darkgrid
set.seed = 2019
x <- 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 = 'lightgrid', fit = 'gam')

mplot3.xy(x, y, theme = 'black', fit = 'gam')

mplot3.xy(x, y, theme = 'blackgrid', fit = 'gam')

mplot3.xy(x, y, theme = 'darkgrid', fit = 'gam')

4.3 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 “darkgrid” theme (works great with a dark RStudio theme), you can use the following:

options(rt.theme = "darkgrid")
options(rt.fit.theme = "darkgrid")
options(rt.palette = "rtCol1")

The first line sets the theme for all mplot3/dplot3 functions that support it, and the second is specific to mplot3.fit. The third line defines the default palette, which works with both light and dark themes.