geomtextpath
geomtextpath copied to clipboard
Long labels with arrow throw cryptic "Error: Cannot create zero-length unit vector ("unit" subsetting)" error
When the label is too long, I get "Error: Cannot create zero-length unit vector ("unit" subsetting)". What is "too long" seems to be device/resolution dependent as the same code worked in other machines and in the reprex, likely due to different screen sizes.
Reprex follows:
library(ggplot2)
super_long_label <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
short_label <- "Lorem ipsum"
ggplot(mtcars, aes(mpg, cyl)) +
geomtextpath::geom_labelsmooth(method = "lm" ,
label = short_label,
arrow = arrow())
#> `geom_smooth()` using formula = 'y ~ x'
ggplot(mtcars, aes(mpg, cyl)) +
geomtextpath::geom_labelsmooth(method = "lm" ,
label = super_long_label,
arrow = arrow())
#> `geom_smooth()` using formula = 'y ~ x'
#> Error: Cannot create zero-length unit vector ("unit" subsetting)
ggplot(mtcars, aes(mpg, cyl)) +
geomtextpath::geom_labelsmooth(method = "lm" ,
label = super_long_label)
#> `geom_smooth()` using formula = 'y ~ x'
Created on 2023-10-23 with reprex v2.0.2