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_colors(
  data,
  xcol,
  ycol,
  match,
  symsize = 3,
  symthick = 1,
  s_alpha = 1,
  ColPal = c("okabe_ito", "all_grafify", "bright", "contrast", "dark", "fishy",
    "kelly", "light", "muted", "pale", "r4", "safe", "vibrant"),
  ColSeq = TRUE,
  ColRev = FALSE,
  SingleColour = "NULL",
  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 grouping 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 "okabe_ito"; see graf_palettes for available palettes.

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 within the selected palette, default F (FALSE); can be set to T (TRUE).

SingleColour

a colour hexcode (starting with #), a number between 1-154, or names of colours from grafify colour palettes to fill along X-axis aesthetic. Accepts any colour other than "black"; use grey_lin11, which is almost black.

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 or ggplot2geom_point.

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.

To plot a graph with a single colour along the X axis variable, use the SingleColour argument.

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")