I create a bar plot using ggplot in combination with plotly and I would like to know if there is a way to display the negative values above the x-axis as positive but with a different color (red) than the blue and also a legend that would clarify that blue are the positive values and red the negatives. Something like:
date<-c(as.Date("2020-09-15", "%Y-%m-%d"),as.Date("2020-09-14", "%Y-%m-%d"),
as.Date("2020-09-13", "%Y-%m-%d"),as.Date("2020-09-12", "%Y-%m-%d"),
as.Date("2020-09-15", "%Y-%m-%d"),as.Date("2020-09-14", "%Y-%m-%d"),
as.Date("2020-09-13", "%Y-%m-%d"),as.Date("2020-09-12", "%Y-%m-%d"))
value<-c(5,6,7,8,-3,-5,6,8)
df<-data.frame(date,value)
# Minimal theme + blue fill color
p<-ggplot(data=df, aes(x=date, y=value)) +
geom_bar(stat="identity", fill="steelblue")+
theme_minimal()+ labs(x = "Date of Specimen Collection",y="Total Tests per Day")
ggplotly(p)
