My question is how to change the title of the ggplot legend. It seems an easy question, but I have tried various ways and still couldn't get it correct.
wd.files <- c("wind_39.9375_-105.3125"," wind_39.9375_-105.4375", "wind_40.0625_-105.3125", "wind_40.0625_-105.4375")
In each txt file, such as "wind_39.9375_-105.3125", there are annual average wind speed from 1950 to 2000, formatted like the following:
I have combined all the txt files together (each file represents wind speed at that grid cell), and got the dataset with three columns: longitude, latitude, and wind speed (at the specific grid cell). I use the code below to plot the surface, but don't know how to change the title of the legend to "Wind speed (m/s)". Could anyone help me with this? Thanks for your help.
wd.yr = as.data.frame(wd.yr,col.names=c('lon','lat','wd')) colnames(wd.yr)<- c('lon', 'lat', 'wd') my_year <- theme_bw() + theme(panel.ontop=TRUE, panel.background=element_blank()) my_fill <- scale_fill_distiller(palette='Spectral') yr.sel = ggplot(wd.yr, aes(y=lat, x=lon, fill=wd) + geom_tile() + my_year + my_fill+ coord_quickmap(xlim=range(wd.yr$lon), ylim=range(wd.yr$lat))+ borders('world', xlim=range(wd.yr$lon), ylim=range(wd.yr$lat), colour='black')+ xlab('Longitude(°)')+ ylab('Latitude(°)') print(yr.sel) # with region boundary