Skip to content

two labels on same curve #87

Description

@yonicd

great package, thanks for developing it!

How would I put two labels on the same curve in the current syntax?

library(ggplot2)

#plot logistic regression curve
fit_data <- glm(vs ~ hp, data = mtcars |> dplyr::filter(hp<=200), family = binomial) |>
  broom::augment(newdata = tibble::tibble(hp = seq(50,200,1)), type.predict = 'response')

fit_data |>
  ggplot(aes(x = hp, y = .fitted)) +
  geomtextpath::geom_labelline(label = 'Low',hjust = 0.18) + 
  geomtextpath::geom_labelline(label = 'High',hjust = 0.45)

Created on 2022-12-14 with reprex v2.0.2

Session info
sessionInfo()
#> R version 4.2.1 (2022-06-23)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_3.3.6
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_4.2.1     pillar_1.8.0       highr_0.9          tools_4.2.1       
#>  [5] digest_0.6.29      evaluate_0.16      lifecycle_1.0.1    tibble_3.1.8      
#>  [9] gtable_0.3.0       pkgconfig_2.0.3    rlang_1.0.4        reprex_2.0.2      
#> [13] cli_3.3.0          rstudioapi_0.13    curl_4.3.2         yaml_2.3.5        
#> [17] xfun_0.32          fastmap_1.1.0      xml2_1.3.3         httr_1.4.3        
#> [21] withr_2.5.0        stringr_1.4.0      dplyr_1.0.9        knitr_1.39        
#> [25] systemfonts_1.0.4  generics_0.1.3     fs_1.5.2           vctrs_0.4.1       
#> [29] grid_4.2.1         tidyselect_1.1.2   glue_1.6.2         R6_2.5.1          
#> [33] textshaping_0.3.6  geomtextpath_0.1.1 fansi_1.0.3        rmarkdown_2.14    
#> [37] farver_2.1.1       tidyr_1.2.0        purrr_0.3.4        magrittr_2.0.3    
#> [41] backports_1.4.1    scales_1.2.0       htmltools_0.5.3    mime_0.12         
#> [45] colorspace_2.0-3   labeling_0.4.2     utf8_1.2.2         stringi_1.7.8     
#> [49] munsell_0.5.0      broom_1.0.0        crayon_1.5.1

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions