How do I insert the legend in this chart, what kind of bar would be the gross total and the line the total net?
lines = 'Mes Acid Obt
Jan 1450 102
Fev 1447 86
Mar 1461 87
Abr 1356 61
Mai 1398 80
Jun 1115 87
Jul 1211 82
Ago 1089 64
Set 1246 86
Out 1128 73
Nov 1204 61
Dez 1435 92'
# Importando dados
obs <-read.table(textConnection(lines),h=T)
# Visualizando a tabela criada
head(obs)
# Niveis
levels(obs$Mes)
# Ordenando niveis
obs$Mes = factor(obs$Mes, levels=c("Jan", "Fev", "Mar", "Abr", "Mai", "Jun",
"Jul", "Ago", "Set", "Out", "Nov", "Dez"))
#Gráfico
library(ggplot2)
ggplot(obs, aes(x = Mes)) +
geom_bar(aes(y = Acid), fill="darkblue", stat = "identity", alpha=0.4) +
geom_point(aes(y = Obt*14), color="#a50026", size=2, group = 1) +
geom_line(aes(y = Obt*14), color="#a50026", size=1, group = 1) +
scale_y_continuous(sec.axis = sec_axis(~./14, name = "Total líquido")) +
labs(y = "Total bruto", x = "Mês")