geomtextpath icon indicating copy to clipboard operation
geomtextpath copied to clipboard

Support for `geom_step()`?

Open baslat opened this issue 1 year ago • 2 comments

Thanks for the package. Any chance of adding a geom_textstep() to work with geom_step() please?

baslat avatar Sep 12 '23 06:09 baslat

Thanks for the interest. I'm not sure how well text paths work on steps, though it might be convenient to add this in the next update. In the meantime it's simple enough to make a geom_step equivalent using geom_textpath with minor data wrangling:

library(geomtextpath)
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 4.1.3

set.seed(1)

df <- data.frame(x = 1:10, y = sample(1:10))

ggplot(df, aes(x, y)) +
  geom_step()


ggplot(data = with(df, data.frame(x = c(rep(x, each = 2), c(x[length(x)])),
                                  y = c(y[1], rep(y, each = 2)))
  )) +
  geom_textpath(aes(x = x, y = y, label = 'This works as a stop gap'))

Created on 2023-09-12 with reprex v2.0.2

AllanCameron avatar Sep 12 '23 12:09 AllanCameron

Thanks, and yes the appearance would depend on the label length and the number of steps, but it works for my use case.

image

baslat avatar Sep 12 '23 20:09 baslat