在GGR绘图中左对齐记号标记标签

在GGR绘图中左对齐记号标记标签,r,ggplot2,visualization,R,Ggplot2,Visualization,我可以在ggplot中找到对齐图例和轴标签的选项,但记号标记标签没有 是否可以使这些标签不与图形打印框右对齐,而是与最长标签的起点或与整个图形边框的某个设定距离左对齐 例如: set.seed(1) library(ggplot2) axisLabels.x <- c("This is a longer label", "Short label", "Short label","Short label","Short label",

我可以在
ggplot
中找到对齐图例和轴标签的选项,但记号标记标签没有

是否可以使这些标签不与图形打印框右对齐,而是与最长标签的起点或与整个图形边框的某个设定距离左对齐

例如:

set.seed(1)
library(ggplot2)
axisLabels.x <- c("This is a longer label", 
              "Short label", "Short label","Short label","Short label",
              "This is again a longer label")
labels.wrap  <- lapply(strwrap(axisLabels.x,50,simplify=F),paste,collapse="\n") # word wrap
gg <- data.frame(x=LETTERS[1:6], y=sample(1:10,6))
ggplot(gg) +
  geom_bar(aes(x,y, fill=x), stat="identity")+
  scale_x_discrete(labels=labels.wrap)+
  scale_fill_discrete(guide="none")+
  labs(x="",y="Response")+
  coord_flip()
set.seed(1)
图书馆(GG2)

axisLabels.x由于它提供了解决方案,我将@user20650的评论作为一个答案

set.seed(1)
library(ggplot2)
axisLabels.x <- c("This is a longer label", 
                  "Short label", "Short label","Short label","Short label",
                  "This is again a longer label")
labels.wrap  <- lapply(strwrap(axisLabels.x,50,simplify=F),paste,collapse="\n") # word wrap
gg <- data.frame(x=LETTERS[1:6], y=sample(1:10,6))
plot <- ggplot(gg) +
  geom_bar(aes(x,y, fill=x), stat="identity")+
  scale_x_discrete(labels=labels.wrap)+
  scale_fill_discrete(guide="none")+
  labs(x="",y="Response")+
  coord_flip()

主题(axis.text.y=element\u text(hjust=0))
可能重复的
plot + theme(axis.text.y = element_text(hjust = 0))