0

I have a problem with labels.I cannot add labels. I get this message :

geom_label requires the following missing aesthetics: x, y and label
Run `rlang::last_error()` to see where the error occurred.

1: Ignoring unknown aesthetics: label 
2: Use of `ust_lks$x` is discouraged. Use `x` instead. 
3: Use of `ust_lks$y` is discouraged. Use `y` instead. 


This is my code:

#library(ggplot2)
#library(ggsoccer)

ggplot(ust_lks) +
  annotate_pitch(dimensions = pitch_custom,
                 colour = "white",
                 fill   = "springgreen4",
                 limits = FALSE) +
  theme_pitch()+
  theme(panel.background = element_rect(fill = "springgreen4"))+
  geom_point(aes(x = ust_lks$x-2, y = ust_lks$y+14,label=rownames(ust_lks)),
             fill = "white",
             color= "red",
             shape = 21,
             size = 8)+
  geom_text()


This is data frame ust_lks enter image description here

Robxaa798
  • 171
  • 6
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. (Images of data are not helpful because we can't copy/paste it to test.) Try moving the `aes()` to the `ggplot()` part rather than the `geom_point()` specifically. Also avoid using `$` inside of `aes()`, `aes(x = x-2, y = y+14,label=rownames(ust_lks))` would be better. – MrFlick Feb 23 '21 at 21:02
  • Yeah, it works. Thanks – Robxaa798 Feb 23 '21 at 21:06

0 Answers0