Comments (5)
Huh, indeed. I just tried it at my home machine and it indeed doesn't seem to work. For now, a workaround is to use linetype = NA
for the label layers. I might have been using an older version at work.
from geomtextpath.
Hi there,
I'd suggest to draw a separate line, then draw the two lables on top with text_only = TRUE
:
library(ggplot2)
library(magrittr)
#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)) +
geom_line() +
geomtextpath::geom_labelline(label = 'Low',hjust = 0.18, text_only = TRUE) +
geomtextpath::geom_labelline(label = 'High',hjust = 0.45, text_only = TRUE)
Created on 2022-12-14 by the reprex package (v2.0.0)
from geomtextpath.
Thanks for using the package @yonicd . I agree with @teunbrand here. We did consider multi-label lines at one point, but I couldn't see a way of doing this without complicating the user interface. I'm going to close this issue for now, as I think Teun's solution is pretty straightforward to implement.
from geomtextpath.
thanks for the quick response!
from geomtextpath.
i cant seem to create the same plot @teunbrand made, are you using a branched version?
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)) +
geom_line() +
geomtextpath::geom_labelline(label = 'Low',hjust = 0.18, text_only = TRUE) +
geomtextpath::geom_labelline(label = 'High',hjust = 0.45, text_only = TRUE)
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
from geomtextpath.
Related Issues (20)
- Long labels with arrow throw cryptic "Error: Cannot create zero-length unit vector ("unit" subsetting)" error
- Strange behaviour of halign HOT 4
- Feature Request: Set angle for geom_labelvline HOT 6
- Feature request - test for text self-overlap on sharp contours HOT 1
- ggplot coord_polar() issue with multiple classes: 'from' must be a finite number error HOT 1
- session aborted when library in Rstudio HOT 2
- Add compatibility with `ggbump` HOT 2
- geom_textsf randomly throws erros when specification of font family is missing (OpenSUSE Leap 15.5, R 4.3.2) HOT 2
- straight argument unknown in geom_textsf() HOT 2
- `label` aesthetic in `geom_textdensity2d` HOT 2
- R 4.3.0 and glyphs 👀 HOT 1
- Can't get things to work HOT 11
- vjust and hjust as aesthetics in geom_textsf HOT 3
- Different behavior for line breaks when there's no data
- geomtextline not accommodating RGBA colors
- show.legend not working in geom_textabline
- Support for `geom_step()`? HOT 2
- Partial match of 'xoff' to 'xoffset'
- geom_textsf seems to ignore remove_long=F
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geomtextpath.