Working with Labels and Annotations:
Solution Exercise 2
ggplot(mapping = aes(x = 0, y = 0)) +
annotation_custom(
grid::rasterGrob(
image = skyline,
x = .5,
y = -.2
)
) +
geom_point(
color = "#71a5d4", size = 150
) +
geom_text(
label = "R", size = 80,
family = "Tabular",
color = "white"
) +
coord_cartesian(clip = "off") +
xlim(-5, 5) +
ylim(-5, 5) +
theme_void() +
theme(
plot.margin = margin(t = 30, b = 120)
)
ggplot(mapping = aes(x = 0, y = 0)) +
annotation_custom(
grid::rasterGrob(
image = skyline,
x = .5,
y = .1
)
) +
geom_point(
color = "#71a5d4", size = 150
) +
geom_text(
label = "R", size = 80,
family = "Tabular",
color = "white"
) +
xlim(-5, 5) +
ylim(-7.5, 5) +
theme_void() +
theme(
plot.background = element_rect(
fill = "#fffdf9", color = "#fffdf9"
)
)
Cédric Scherer // rstudio::conf // July 2022