Customize inset shape and appearance
masterYou can modify the visual style of the magnified inset using several arguments in geom_magnify():
- Shadows: Set
shadow = TRUEto add a drop shadow. This requires theggfxpackage. You can customize shadow properties viashadow.args = list(colour = "...", sigma = ..., x_offset = ..., y_offset = ...). - Rounded Corners: Use
corners = <numeric>to provide a proportional radius for rounded corners. - Ellipse Shape: Set
shape = "ellipse"to create an elliptical inset (requires R 4.1+ and an appropriate graphics device). - Outline Shape: Set
shape = "outline"to magnify the convex hull of a set of points (useful for arbitrary regions or maps). Useexpand = <numeric>to adjust the expansion of the outline. - Custom Shapes: Pass a
grid grobobject or adata.frameof coordinates to thefromargument to magnify an arbitrary shape.
# Ellipse example
ggp + geom_magnify(from = from, to = to, shape = "ellipse", shadow = TRUE)
# Rounded corners with shadow
ggp + geom_magnify(from = from, to = to, corners = 0.1, shadow = TRUE)
# Arbitrary shape from a data frame
s <- seq(0, 2*pi, length = 7)
hex <- data.frame(x = 3 + sin(s)/2, y = 6 + cos(s)/2)
ggpi + geom_magnify(from = hex, to = c(4, 6, 5, 7), shadow = TRUE, aspect = "fixed")