Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrating textpath with stat_halfeye #247

Open
yonisidi opened this issue Sep 19, 2024 · 1 comment
Open

integrating textpath with stat_halfeye #247

yonisidi opened this issue Sep 19, 2024 · 1 comment

Comments

@yonisidi
Copy link

I am trying to use {geomtextpath} to label different parts of a distribution visually and am having trouble figuring out how to blend the two packages together.

i am using stat_function as my solution in with the geom set to textpath.

any ideas how i can achieve this? thanks!

  plot_tbl <- tibble::tibble(
    dist = "lnorm", 
    label = c('>=3', '>=4',  '>=6', '>=8'),
    logmean = c(log(7),log(9), log(12), log(18)), 
    logsd = log(3.5)
  )

  plot_tbl |>
    ggplot() +
    ggdist::stat_halfeye(aes(
     y = factor(label), dist = dist, arg1 = logmean, arg2 = logsd,
     fill = after_stat(x < 6)), show.legend = FALSE) +
    stat_function(
    aes(y = '>8'),
      geom = 'textpath', 
      fun = dlnorm, 
      label = 'aaa',
      size = 5, 
      vjust = -0.2, 
      hjust = 0.1, 
      args = list(meanlog = log(18), sdlog = log(3.5))
    ) +
    scale_x_log10(breaks = 10^seq(-5,7, by = 2))

image

@mjskay
Copy link
Owner

mjskay commented Nov 20, 2024

Yeah this is hard --- would probably need something like #217 so that thickness values could be translated into y values for that geom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants