Is there a way to blur a certain part of a plot in ggplot
?
For example, consider the following plot:
library(ggplot2)
library(magrittr)
p <-
mtcars %>%
ggplot(aes(x = disp, y = mpg)) +
geom_line() +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())
p +
annotate("rect", xmin = 100, xmax = 200, ymin = 15, ymax = 30,
alpha = .1,fill = "red")
Created on 2021-07-22 by the reprex package (v2.0.0)
Desired Output
I want to apply a blur effect in p
over the area where there's currently a red rectangle.
A demonstration of what I'm looking for:
Is this even possible?
Reference: Similar question (and answer) in python.