add a legend to a ggplot2 plot

Hello can you teach me how to add a legend to this plot thank you

#AIA Lose  
LAplot2 <- ggplot(LoseAIA, aes(Instrument, LALsen))+
  xlab("Instrument Type") +ylab(" Estimated Loss ($k) / Year") +
  scale_y_continuous(limits=c(0,100), breaks=seq(0, 100,by=20))+
  geom_jitter(colour = "red") +
  scale_x_discrete(limits=c("AIA-360", "AIA-600II", "AIA-900ST", "AIA-900+9", "AIA-900+19", "AIA-1800", "AIA-2000")) +
  theme_classic()

#AIA Win
WARsen <- WinAIA$AnnualizedRevenue.2018/1000

WAplot <- ggplot(WinAIA, aes(Instrument, WARsen))+
  xlab("Instrument Type") +ylab(" Estimated Revenue ($k) / Year") +
  scale_y_continuous(limits=c(0,100), breaks=seq(0, 100,by=50))+
  geom_jitter(colour = "blue") +
  scale_x_discrete(limits=c("AIA-360", "AIA-600II", "AIA-900ST", "AIA-900+9", "AIA-900+19", "AIA-1800", "AIA-2000")) +
  theme_classic(+ theme(legend.position="right"))

If the info in this thread didn't help you, definitely open up a question of your own to ask for help. :slightly_smiling_face:

You will want to include a reproducible example (aka "reprex"), which will include an example of your dataset.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.