My data:
df <- data.frame(sp = c(LETTERS[1:8]),
tr = c(\"NS\", \"LS\", \"NS\", \"LS\", \"LS\", \"HS\", \"HS\", \"HS\"),
bv =
You can remove the variable
legend by setting fill = FALSE
in guides
and you change the backgroundcolor with override.aes
in guide_legend
(also inside guides
) as follows:
ggplot(df1, aes(sp, value, fill = variable)) +
geom_bar(aes(lty = tr), lwd = 1.2, stat = "identity", colour = "black", width =.8) +
scale_linetype_discrete(name = "ja") +
guides(fill = FALSE,
lty = guide_legend(override.aes = list(lty = c('dotted', 'dashed', 'solid'),
fill = "white"))) +
theme_classic() +
theme(legend.position = "bottom")
this results in the following plot: