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

Warning messages: "All aesthetics have length 1, but the data has XX rows" #115

Closed
jfgomezok opened this issue Apr 17, 2024 · 2 comments
Closed

Comments

@jfgomezok
Copy link

I'm new to the package, which is GREAT by the way, kudos to all of you!

I use it mainly for the geom_texthline, which is working fine, but I have this warning message in the console every time. In fact, if I try the example of the help page of the function, I get the same warning message (which is same same warning you have here in github: https://github.com/AllanCameron/geomtextpath?tab=readme-ov-file#reference-lines):

> ggplot(mtcars, aes(mpg, disp)) +
+   geom_point() +
+   geom_texthline(yintercept = 200, label = "displacement threshold",
+                  hjust = 0.8, color = "red4") +
+   geom_textvline(xintercept = 20, label = "consumption threshold", hjust = 0.8,
+                  linetype = 2, vjust = 1.3, color = "blue4") +
+   geom_textabline(slope = 15, intercept = -100, label = "partition line",
+                   color = "green4", hjust = 0.6, vjust = -0.2)
Warning messages:
1: In geom_texthline(yintercept = 200, label = "displacement threshold",  :
  All aesthetics have length 1, but the data has 32 rows.
ℹ Did you mean to use `annotate()`?
2: In geom_textvline(xintercept = 20, label = "consumption threshold",  :
  All aesthetics have length 1, but the data has 32 rows.
ℹ Did you mean to use `annotate()`?

Would be great to not have a warning message! Many thanks!

@psychelzh
Copy link

See tidyverse/ggplot2#5762 for related discussions. Possibly a false positive for newer ggplot2.

@AllanCameron
Copy link
Owner

Yes, this is not really a geomtextpath issue; it is new behaviour in the latest version of ggplot2, and it is a good thing. You would get the same warning if you change geom_textvline to geom_vline, etc.

The point is that if you add these lines as geom layers rather than annotations, you actually get one line for each row of the data frame. The example on the GitHub was written before the change in ggplot, and was due to my misguided attempt to make the code as succinct as possible.

Whilst it would be possible to "fix" this so that you don't get the warnings, I don't want the behaviour of these geoms to differ from their ggplot equivalents.

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

3 participants