11.66 Text Path Clock Multiple Plots
20220109

clock <- function(x)
{
hours <- c(rep(x[1] %% 12 + tail(x, 1) / 60, 2), 0, 3.5)
minutes <- c(rep(tail(x, 1)/5, 2), 0, 5)
as.data.frame(rbind(hours, minutes)) %>%
ggplot(aes(V1, V3)) +
geom_segment(aes(xend=V2, yend=V4),
size=c(2, 1),
lineend="round") +
geom_point(x=0, y=0, size=6) +
scale_x_continuous(limits=c(0, 12),
breaks=1:12,
label=as.roman) +
scale_y_continuous(limits=c(0, 6),
expand=c(0, 0)) +
theme_void() +
theme(plot.margin=unit(c(30,15,30,15), "pt"),
axis.text.x=element_text(size=10, face=2))
}
c1 <- clock(10:10) + coord_polar()
c2 <- clock(8:20) + coord_polar()
n <- now(); h <- lubridate::hour(n); m <- lubridate::minute(n)
c3 <- clock(h:m) + coord_polar()
c1 + c2 + c3The clock is an example from geomtextpath (Cameron and van den Brand 2025) and
demonstrates a nice hack to produce a clock face. Any time can be
specified in the call to clock().
In our example we have three clocks generated and using
patchwork (Pedersen 2025) the multiple plots are displayed as a single
plot through the + operator.
References
Cameron, Allan, and Teun van den Brand. 2025. Geomtextpath: Curved Text in Ggplot2. https://allancameron.github.io/geomtextpath/.
Pedersen, Thomas Lin. 2025. Patchwork: The Composer of Plots. https://patchwork.data-imaginist.com.
If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0