R/makeQuartilePlot.R

Defines functions makeQuartilePlot

# Display four equally likely intervals as coloured bars
# This is used in the elicit() app to plot a single set of judgements
# Different to plotQuartiles() for comparing quartiles from multiple experts

makeQuartilePlot <- function(lower, Q1, m, Q3, upper, fontsize=12, xlab = "x"){
  ggplot()+
    annotate("rect", xmin = lower, 
             xmax = Q1, ymin=0.2, ymax = 0.8, fill = "#a6cee3")+
    annotate("rect", xmin = Q1, xmax = m, 
             ymin=0.2, ymax = 0.8, fill = "#1f78b4")+
    annotate("rect", xmin = m, xmax = Q3, ymin=0.2, ymax = 0.8, fill = "#b2df8a")+
    annotate("rect", xmin = Q3, xmax = upper, ymin=0.2, ymax = 0.8, fill = "#33a02c")+
    xlim(lower, upper)+
    theme(axis.ticks.y = element_blank(), axis.text.y = element_blank())+
    scale_y_continuous(breaks = NULL, limits = c(0, 1))+
    labs(title = "Quartiles", y = expression(f[X](x)), x = xlab) +
    theme(plot.title = element_text(hjust = 0.5),
          axis.title.y = element_text(colour = "white"),
          text = element_text(size = fontsize))
  
}

Try the SHELF package in your browser

Any scripts or data that you put into this service are public.

SHELF documentation built on Sept. 11, 2024, 6:54 p.m.