I have a plot like this:
library(ggplot2)
ggplot() +
geom_function(fun = ~ 2*-.x^2 + 2*.x + 3)
Now I want to "highlight" one segment of the curve as on the following photo made in Paint:
How can I achieve that?
>Solution :
You can add an xlim argument to a second geom_function
library(ggplot2)
ggplot() +
geom_function(fun = ~ 2*-.x^2 + 2*.x + 3) +
geom_function(fun = ~ 2*-.x^2 + 2*.x + 3, xlim=c(.25, .5), color = 'blue', size = 2)

Created on 2022-11-15 by the reprex package (v2.0.0)

