Example graph:
data.frame(x = c(1,2,3,5,2,3,4,6), y = c(2,3,4,1,4,7,4,1)) %>% ggplot() + geom_point(aes(x = x, y = y)) + annotate('text', x = 3, y = 3, label = 'Heres a plot annotation', size = 5)
...here is the output of the graph from the above code, saved when the graph's width is 500px
...and here's the same graph at 250 pixel width
I'm interesting in finding a way for the annotation text to scale with the width of the ggplot(), that way the text doesn't overflow outside of the graph when the width is smaller (or look too small when the graph becomes larger). In the code above, size = 5
clearly sets a fixed-pixel size font that doesn't scale with the width of the graph. Is there anyway to change this, so the font-size does scale with width?