Não sei o que estou fazendo errado, pois a legenda não aparece no gráfico que construo. Segue meu código:
ND<-c("D0","D1","D2","D3e4") #diferentes níveis de desfolha (D)
Vreal<-c(0.1985479,0.2060983,0.1611603,0.1214494) #volume real das árvores
Vest_g=c(0.1892300,0.1964590,0.1529276,0.1296224) #vol estimado sem considerar D
Vest_d=c(0.1970788,0.2039802,0.1607308,0.1186836) #vol estimado considerando D
EP_Vreal=c(0.007480623,0.009235496,0.010960471,0.008099734) #Erro padrão da média
EP_Vest_g=c(0.007224098,0.008119300,0.009906934,0.008238645)
EP_Vest_d=c(0.005887057,0.007898459,0.010907461,0.007151453)
Volume<-data.frame(ND,Vreal,Vest_g,Vest_d,EP_Vreal,EP_Vest_g,EP_Vest_d)
# plot dataframe
ggplot(Volume, aes(x = ND)) +
labs(x = "Níveis de desfolha",
y = "Vol. ind. total com casca (m³)") +
theme(legend.position="top")+
scale_fill_discrete(name="Legenda",
labels=c("Vreal", "Vest_g", "Vest_d")) +
geom_bar(
aes(y = Vreal),
stat = "identity",
fill = "seagreen1",
width = .2,
position = position_nudge(x = -.20),
) +
geom_errorbar(aes(ymin = Vreal-EP_Vreal, ymax = Vreal+EP_Vreal), position = position_nudge(x = -.20), width = 0.1) +
geom_bar(
aes(y = Vest_g),
stat = "identity",
fill = "darkturquoise",
width = .2,
position = position_nudge(x = 0)
) +
geom_errorbar(aes(ymin = Vest_g-EP_Vest_g, ymax = Vest_g+EP_Vest_g), position = position_nudge(x = 0), width = 0.1) +
geom_bar(
aes(y = Vest_d),
stat = "identity",
fill = "cyan",
width = .2,
position = position_nudge(x = .20)
) +
geom_errorbar(aes(ymin = Vest_d-EP_Vest_d, ymax = Vest_d+EP_Vest_d), position = position_nudge(x = .20), width = 0.1)
Resultado: gráfico sem legenda