My dataframe looks something like this:
df = data.frame(
measure = c("Measure A","Measure B","Measure C"),
overall = c(9, 5, 11),
company = c(4,6,3)
)
I am trying to plot bars for the company, and using geom_point, "lines" for the overall. For some reason, the company color fill and label for the legend doesn't change even though my code specifies it:
ggplot(df, aes(measure)) + geom_col(aes(y=company, fill="company")) + geom_point(aes(y=overall, color="overall"), size=8, shape=124) +
scale_color_manual(values=c("company" = "yellow", "overall"="blue"),labels=c("company" = "Your Company", "overall"= "Overall Benchmark")) +
coord_flip()+ guides(size=FALSE) + theme(legend.box="horizontal",legend.key=element_blank(), legend.title=element_blank(),legend.position="top")
The bars stay red and the legend reads company regardless. Is there a way to fix this?
fill
for the bars.scale_color_manual
is forcolor
, notfill
. Usescale_fill_manual
to change thefill
color and labels. – aosmith