I'm creating a graph of air temperatures in two locations, denoted on the plot by solid lines (location 1) and dashed lines (location 2). I've added geom_label
annotations to display the min and max temperatures as text, and I would really like for the boxes surrounding the text to correspond to the linetypes already on the plot (i.e. solid boxes for location 1 labels; dashed boxes for location 2 labels).
Code-wise, I currently have
ggplot() +
geom_line(data = sum_BHBM3, aes(x = MM, y = minATMP), col = "dodgerblue2") +
geom_line(data = sum_44013, aes(x = MM, y = meanATMP), col = "black") +
geom_line(data = sum_44013, aes(x = MM, y = maxATMP), col = "firebrick3") +
geom_line(data = sum_BUZM3, aes(x = MM, y = minATMP), col = "dodgerblue2", linetype = "22") +
geom_line(data = sum_BUZM3, aes(x = MM, y = meanATMP), col = "black", linetype = "22") +
geom_line(data = sum_NWPR1, aes(x = MM, y = maxATMP), col = "firebrick3", linetype = "22") +
annotate("label", label = "10-yr min: -21.9°C", col = "dodgerblue2", x = 3.75, y = -21) +
annotate("label", label = "10-yr max: 30.1°C", col = "firebrick3", x = 7.9, y = 25) +
annotate("label", label = "10-yr min: -16.5°C", col = "dodgerblue2", x = 2, y = -5) +
annotate("label", label = "10-yr max: 35.5°C", col = "firebrick3", x = 4.4, y = 34.5)
...
I've tried adding linetype = "22"
to the annotate
lines to create a dashed outline, as in
annotate("label", label = "10-yr min: -16.5°C", col = "dodgerblue2", x = 2, y = -5, linetype = "22")
but it generates the "unknown parameters" warning message and thus appears to be invalid. I've also been unable to find any resources online covering this situation.
Is there a way to set the linetype of the box surrounding a label geom, specifically to a dashed line?