Hello, I have the following map produced by ggplot2 and I would like to change the headers associated with the continuous variables in the legend:
I would like for the legend to say "Max Temp" and "Concentration (ug/L)", instead of the current headers based on the column names. I tried using scale_linetype_manual
but it doesn't recognize my values. I tried scale_linetype_continuous
but I got an error saying Error: A continuous variable can not be mapped to linetype
. Does anyone know of a way to change the legend headers of continuous data in ggplot?
Here is my current plot code:
TOT_map <- ggplot() +
geom_sf(data=gb.shp) +
geom_sf(data=sf_fp,
aes(col=Mean_Total_Conc_ug.L,
size=Max_Temp_C),
na.rm=F) +
theme(axis.text.x = element_blank(), # remove x-axis text
axis.text.y = element_blank(), # remove y-axis text
axis.ticks = element_blank(), # remove axis ticks
axis.title.x = element_blank(), # remove x-axis labels
axis.title.y = element_blank(), # remove y-axis labels
panel.background = element_blank(),
panel.grid.major = element_blank(), #remove major-grid labels
panel.grid.minor = element_blank(), #remove minor-grid labels
plot.background = element_blank()) +
labs(title="Mean Total Algal Concentrations (ug/L)") +
scale_linetype_continuous(limits = c("Max_Temp_C", "Mean_Total_Conc_ug.L"),
labels = c("Max Temp", "Concentration (ug/L)"))
Thank you so much!!