![]() We need a couple of helper functions here: next_x_along_sine <- function(x, d) We need to space the letters evenly along the path, which requires working out the x co-ordinates that achieve this. We can split the label into characters: label <- strsplit(label, "")] Say we have the following plot: library(ggplot2)ĭf <- ame(y = sin(seq(0, pi, length.out = 100)),Īnd the following label that we want to run along it: label <- "PIRATES VS NINJAS" I don't know of any packages that allow it natively, but it's not terribly difficult to do it yourself, since geom_text accepts angle as an aesthetic mapping. Ggplot(df, aes(x = duration, group = monthly_run, color = monthly_run)) + Monthly_run = c('March', 'March', 'March', 'March', 'March', 'March', 'March', I'm also curious if there is a name for this style of text-along-line?Įxample ggplot2 graph using annotate(.):Ībove example graph modified with curved text in Inkscape:Įdit: Here's the data for the first two trial runs in March and April, as requested: df <- ame( ![]() ![]() I know I can place a straight/flat piece of text, such as via annotate or geom_text, but I'm curious about bending such text so it appears to be along the curve of the data. Note: I'm not talking about the hand-drawn xkcd style, nor putting flat labels at the top Alternatively, is there a way to have the line be repeating text, such as this xkcd #930 ? My apologies for all the xkcd, I'm not sure what these styles are called, and it's the only place I can think of that I've seen this before to differentiate areas in this way. Is there a way to put text along a density line, or for that matter, any path, in ggplot2? By that, I mean either once as a label, in this style of xkcd: 1835, 1950 (middle panel), 1392, or 2234 (middle panel). ![]()
0 Comments
Leave a Reply. |