I find it difficult to combine the text of the legend on the left.
library(ggplot2) library(reshape2) o3<- rnorm(1827, 50, 10) NO2<- rnorm(1827, 35, 7) NOx<- rnorm(1827, 45, 10) pm25<- rnorm(1827, 15, 4) date<-seq(as.Date('2000-01-01'),as.Date('2004-12-31'),by = 1) df<-data.frame(date,o3,NO2,NOx,pm25) meltdf <- melt(df,id="date")
With this code, alignment is automatically left
ggplot(meltdf, aes(x = date, y = value, colour =variable)) + geom_smooth() + stat_smooth(method = "gam")
However, with the following alignment is the center.
ggplot(meltdf, aes(x = date, y = value, colour =variable)) + geom_smooth() + stat_smooth(method = "gam") + scale_color_discrete(name="Pollutant" ,labels = c(expression(O[3]), expression(NO[2]), expression(NO[x]), expression(PM[2.5])))
How could I achieve left alignment with the last script?