The plot_befafter_colours, plot_befafter_colors and plot_befafter_shapes are for plotting matched data joined by lines. These functions take X and Y variables along with a data column with matching information (e.g. matched subjects or experiments etc.) and plot symbols matched by colour or shape.

plot_befafter_colours(
  data,
  xcol,
  ycol,
  match,
  symsize = 3,
  symthick = 1,
  s_alpha = 1,
  ColPal = "all_grafify",
  ColSeq = TRUE,
  ColRev = FALSE,
  TextXAngle = 0,
  fontsize = 20,
  groups,
  ...
)

Arguments

data

a data table object, e.g. data.frame or tibble.

xcol

name of the column containing the categorical variable to be plotted on the X axis.

ycol

name of the column containing the quantitative Y values.

match

name of the column with the matching variable to pass on to geom_line.

symsize

size of symbols, default set to 3.

symthick

thickness of symbol border, default set to 1.

s_alpha

fractional opacity of symbols, default set to 1 (i.e. maximum opacity & zero transparency).

ColPal

grafify colour palette to apply, default "all_grafify"; alternatives: "okabe_ito", "bright", "pale", "vibrant", "contrast", "muted" "dark", "light".

ColSeq

logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours, which will be applied using scale_fill_grafify2.

ColRev

whether to reverse order of colour choice, default F (FALSE); can be set to T (TRUE).

TextXAngle

orientation of text on X-axis; default 0 degrees. Change to 45 or 90 to remove overlapping text.

fontsize

parameter of base_size of fonts in theme_classic, default set to size 20.

groups

old argument name for match; retained for backward compatibility.

...

any additional arguments to pass to ggplot2geom_line.

Value

This function returns a ggplot2 object of class "gg" and "ggplot".

Details

Note that only 25 shapes are available, and there will be errors with plot_befafter_shapes when there are fewer than 25 matched observations; instead use plot_befafter_colours instead.

Colours can be changed using ColPal, ColRev or ColSeq arguments. ColPal can be one of the following: "okabe_ito", "dark", "light", "bright", "pale", "vibrant, "muted" or "contrast". ColRev (logical TRUE/FALSE) decides whether colours are chosen from first-to-last or last-to-first from within the chosen palette. ColSeq decides whether colours are picked by respecting the order in the palette or the most distant ones using colorRampPalette.

More complex designs can also be plotted when used with facet_wrap or facet_grid.

Examples

#plot without legends if necessary
plot_befafter_colors(data = data_t_pdiff, 
xcol = Condition, ycol = Mass, 
match = Subject, s_alpha = .9, ColSeq = FALSE)+
guides(fill = "none", 
colour = "none") #remove guides

#2way ANOVA design with randomised blocks
plot_befafter_colors(data = data_2w_Tdeath, 
xcol = Genotype, ycol = PI, 
match = Experiment) + facet_wrap("Time")