Three or more variables

Graphs with more than two variables with blocking factor/repeated-measures (e.g. factorial ANOVAs)


Data format

See the data help page and ensure data table is in the long-format.

Saving graphs

See Saving graphs for tips on how to save plots for making figures.

Experimental designs

The d in the name stands for dimensions or variables in the data. plot_3d... functions are for 1-way ANOVA and plot_4d_... for 2-way ANOVA with randomised blocks; plot_4d_... require a second categorical factor that is mapped to bars or boxes through the bars or boxes argument, respectively.

These functions are generally useful when a third variable needs to be plotted to shapes of symbols. This is handy for plotting experiments with randomised blocks or repeated measures, where the shape of the symbol (shapes argument) is mapped to a “blocking factor” variable in the data table.

plot_3d_point_sd, plot_3d_scatterbar or plot_3d_scatterbox

These functions plot bars or box and whisker plots, with the fill aesthetic mapped to the categorical X variable, and shapes to the blocking factor.

Error bars in the point and bar graphs represent standard deviation (SD) by default. they can be changed to SEM or CI95 using the ErrorType argument.

plot_3d_point_sd(data_1w_death,
                 Genotype,          #categorical X variable
                 Death,             #numeric Y variable
                 Experiment,        #blocking factor
                 ColPal = "fishy",  #"contrast" palette
                 ColRev = T)+       #reverse colour order
  labs(title = "1way RB, mean/SD",
       subtitle = "(reverse `fishy` palette)")
plot_3d_point_sd(data_1w_death,
                 Genotype,          #categorical X variable
                 Death,             #numeric Y variable
                 Experiment,        #blocking factor
                 ErrorType = "SEM", #SEM error bars  
                 ColPal = "kelly",  #"contrast" palette
                 ColRev = T)+       #reverse colour order
  labs(title = "1way RB, mean/SEM",
       subtitle = "(reverse `kelly` palette)")

The box represents IQR with a thick line representing the median, and whiskers depict 1.5*IQR.

There are several additional arguments, including ewid, symsize, symthick, fontsize, jitter, s_alpha and b_alpha, which are similar to plot_scatterbar_sd or plot_scatterbox version for plotting two variables.

plot_3d_scatterbar(data_1w_death,
                   Genotype,             #categorical X variable
                   Death,                #numeric Y variable
                   Experiment,           #blocking factor
                   ColPal = "fishy",  #"contrast" palette
                   ColRev = T)+          #reverse colour order
  labs(title = "1way RB, bar/SD",
       subtitle = "(reverse `fishy` palette)")
plot_3d_scatterbox(data_1w_death,
                   Genotype,             #categorical X variable
                   Death,                #numeric Y variable
                   Experiment,           #blocking factor
                   ColPal = "kelly",  #"contrast" palette
                   ColRev = T)+          #reverse colour order
  labs(title = "1way RB, box/whiskers",
       subtitle = "(reverse `kelly` palette)")

plot_3d_ in single colour

plot_3d_scatterbox(data_1w_death, #data table   
                   Genotype,      #X variable
                   Death,         #Y variable
                   Experiment,    #shape variable
                   SingleColour = "pale_red")+ #colour
  labs(title = "1w RB ANOVA, single colour")
plot_3d_scatterbox(data_1w_death, #data table   
                   Genotype,      #X variable
                   Death,         #Y variable
                   Experiment,    #shape variable
                   SingleColour = graf_palettes$bright[1])+ #colour
  labs(title = "1w RB ANOVA, single colour")

plot_4d_point_sd, plot_4d_scatterbar & plot_4d_scatterbox

These functions additionally need a points, bars or boxes argument for the second categorical variable in the 2-way ANOVA.

Since v4.0, the shapes argument can be left empty to plot a simple/ordinary ANOVA, or assigned a variable for the blocking factor/repeated measures. Also the ANOVA plots vignette.

In plot_4d_point_sd, default error bars denote SD, which can be changed to SEM or CI95 using the ErrorType argument.

plot_4d_point_sd(data_2w_Tdeath,           #data table
                   Genotype,                 #categorical X variable
                   PI,                       #numeric Y variable
                   Time,                    #2nd categorical factor
                   Experiment,    #shapes
                   bwid = .7)+    #bar width
  labs(title = "2way/RM, mean/SD",
       subtitle = "(shapes = randomised blocks)")
plot_4d_point_sd(data_2w_Tdeath,           #data table
                   Genotype,                 #categorical X variable
                   PI,                       #numeric Y variable
                   Time,                     #2nd categorical factor
                   ColPal = "r4")+    #colour palette
  labs(title = "2way simple ANOVA",
       subtitle = "(no `shapes` arugment)")

Here are 2way ANOVAs with bars or box and whiskers.

plot_4d_scatterbar(data_2w_Tdeath,           #data table
                   Genotype,                 #categorical X variable
                   PI,                       #numeric Y variable
                   Time,                    #2nd categorical factor
                   Experiment,    #shapes
                   bwid = .7)+    #bar width
  labs(title = "2way/RM, bars/SD",
       subtitle = "(shapes = randomised blocks)")
plot_4d_scatterbox(data_2w_Tdeath,           #data table
                   Genotype,                 #categorical X variable
                   PI,                       #numeric Y variable
                   Time,                     #2nd categorical factor
                   Experiment,
                   ColPal = "r4")+    #colour palette
  labs(title = "2way/RM, box/whiskers",
       subtitle = "(shapes = randomised blocks)")