Does anyone know how to add an annotation color bar to a ggplot or ggvis/plotly/... barplot?
An example would be like "Heatmap 1" below, with a color bar (blue and red) representing sample information as type a or type b:

Does anyone know how to add an annotation color bar to a ggplot or ggvis/plotly/... barplot?
An example would be like "Heatmap 1" below, with a color bar (blue and red) representing sample information as type a or type b:

 
    
    If you use the type a/type b variable for the fill aesthetic you will get colored bars and a legend.
suppressPackageStartupMessages(library(tidyverse))
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome, fill=trt)) +
  geom_col()

