2

using following code, I can get labels using geom_text but they are not vertical, even after I change angle to 90.

 p1 <- ggplot(segment(p)) +
         geom_segment(aes(x=x,y=y,xend=xend,yend=yend),colour="blue") + labs(y = "Label y") +
         theme_classic()+theme(axis.line.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank(),axis.title.x=element_blank()) + 
         geom_text(data=leaf_label_data, aes(x=xend, y=yend,label=label,angle = 90))
Hack-R
  • 22,422
  • 14
  • 75
  • 131
Lav Patel
  • 1,027
  • 1
  • 8
  • 12
  • 1
    Can you please make this into a reproducible example? It's especially important for graphing questions. http://stackoverflow.com/help/mcve http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Hack-R Jun 29 '16 at 22:56
  • Try removing `angle=90` from the aes statement. – Sandy Muspratt Jun 29 '16 at 23:18

1 Answers1

5

You added angle = 90 to aes() but it is no aesthetic. Just move it out of aes and it should work.

A simple example:

ggplot(df, aes(x = x, y = y)) + 
  geom_point() +
  geom_text(aes(label = label), angle = 90, hjust = -0.1)
Alex
  • 4,925
  • 2
  • 32
  • 48