How to rotate the label like geom_text(angle=45)

7,681 views
Skip to first unread message

cqzan

unread,
Nov 23, 2016, 10:13:14 AM11/23/16
to ggplot2

thanyou .

Xingmin Zhang

unread,
Nov 23, 2016, 1:18:59 PM11/23/16
to ggplot2
Do a ?geom_text in your console to read the manual. 

It's like this:
df <- data.frame(
  x = factor(c(1, 1, 2, 2)),
  y = c(1, 3, 2, 1),
  grp = c("a", "b", "a", "b")
)
ggplot(df) + geom_point(aes(x=x, y=y)) + geom_text(aes(x=x,y=y,label=grp),hjust=-0.7,vjust=-0.1,angle=45,size=12)



On Wednesday, November 23, 2016 at 9:13:14 AM UTC-6, cqzan wrote:

thanyou .

cqzan

unread,
Nov 24, 2016, 7:03:12 AM11/24/16
to ggplot2
谢谢,我是想问把图中有背景颜色的也变为45度的怎么弄,p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars)))
p +geom_label(aes(fill=factor(cyl))),然后怎么把他旋转。。

Xingmin Zhang於 2016年11月24日星期四 UTC+8上午2時18分59秒寫道:
Reply all
Reply to author
Forward
0 new messages