# A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# Define a graphical object
circle <- grid::circleGrob()
# Rendering a grob as a guide
p + guides(custom = guide_custom(circle, title = "My circle"))
# Controlling the size of the grob defined in relative units
p + guides(custom = guide_custom(
circle, title = "My circle",
width = unit(2, "cm"), height = unit(2, "cm"))
)
# Size of grobs in absolute units is taken directly without the need to
# set these manually
p + guides(custom = guide_custom(
title = "My circle",
grob = grid::circleGrob(r = unit(1, "cm"))
))
Run the code above in your browser using DataLab