2014-12-21 8 views
14

mam działkę takiego:Jak obrócić tylko tekst w adnotacji w ggplot?

fake = data.frame(x=rnorm(100), y=rnorm(100)) 

ggplot(data=fake, aes(x=x, y=y)) + geom_point() + theme_bw() + 
    geom_vline(xintercept=-1, linetype=2, color="red") + 
    annotate("text", x=-1, y=-1, label="Helpful annotation", color="red") 

enter image description here

Jak bym się obracać tylko z adnotacją tekstowych o 90 stopni, tak że jest równoległa do linii odniesienia?

Odpowiedz

33

Wystarczy powiedzieć, jaki kąt chcesz.

ggplot(data = fake, aes(x = x, y = y)) + 
    geom_point() + 
    theme_bw() + 
    geom_vline(xintercept = -1, linetype = 2, color = "red") + 
    annotate(geom = "text", x = -1, y = -1, label = "Helpful annotation", color = "red", 
      angle = 90) 

W ?geom_text widać, że jest to możliwe angle estetyczny i annotate minie go wraz podobnie jak wszystko inne.