R 打印的文本标签

R 打印的文本标签,r,R,我想用这个图: dtf1 <- data.frame(ID = c(1:10),text = c("my", "and","keep","any","somenone", "exist","tr", "ggplot2","euf","edff"), Diff = c(-5:4), stringsAsFactors = FALSE) dtf1就像其中一条建议的评论: 库(ggplot2) dtf1基本上与上述内容相同,只是如果您愿意,我们使用geom_标签 ggplot(dtf1

我想用这个图:

    dtf1 <- data.frame(ID = c(1:10),text = c("my", "and","keep","any","somenone",
"exist","tr",
"ggplot2","euf","edff"), 
Diff = c(-5:4), stringsAsFactors = FALSE)

dtf1就像其中一条建议的评论:

库(ggplot2)

dtf1基本上与上述内容相同,只是如果您愿意,我们使用
geom_标签

ggplot(dtf1,aes(ID,Diff,label="",hjust=hjust))+
  geom_bar(stat="identity",position="identity",aes(fill = colour))+
  scale_fill_manual(values=c(positive="firebrick1",
                             negative="steelblue"))+
  geom_label(aes(label=text))+
  coord_flip()
geom_文本(aes(label=dtf1$text))
ggplot(dtf1,aes(ID,Diff,label="",hjust=hjust))+
  geom_bar(stat="identity",position="identity",aes(fill = colour))+
  scale_fill_manual(values=c(positive="firebrick1",
                             negative="steelblue"))+
  geom_label(aes(label=text))+
  coord_flip()