I am trying to add a legend to my graph. I made a bar plot with an overlay line plot. I was under the impression that if you put col, fill, ect. in aes(), however, I'ed tried this many different times and many different ways, and it does not work for me.
If someone could help me, I would be so grateful!
My code is as follows:
load("H:\\Personal\\anti.csv") d=read.csv("anti.csv", header=T) library(ggplot2) Day <- d$Ordering Tests<- d$Amount Positive<- d$Positive Rate<- d$Rate now = data.frame(type=c("Positive", "Tests")) now coeff<- 0.33 ggplot(d, aes(x=Day, legend)) + geom_bar(aes(y = Tests), stat="identity", size = 1, color = "#0072B5FF", fill="#6F99ADFF") + geom_line(aes(y=Rate*coeff), size = 1.2, color="#E18727FF", group=1) + scale_y_continuous(sec.axis = sec_axis(~.*3, name = "Rate of Positive Tests")) + labs(title="Tests", x="Day", y="Tests Ordered") + theme_minimal() + theme(axis.title.y=element_text(color="#6F99ADFF"), axis.title.y.right=element_text(color="#E18727FF")) + theme(plot.title=element_text(hjust=0.5))