R ggpplot2中的轴文本对齐

R ggpplot2中的轴文本对齐,r,ggplot2,R,Ggplot2,我使用ggplot2绘制了以下条形图 我们可以观察到,x轴文本没有与x轴对齐,而是居中对齐。如何使所有x轴文本与x轴对齐? 我已尝试更改中讨论的axis.text.x=element\u text(angle=90,vjust=1,hjust=1)中的值,但无效 用于打印的代码如下所示: p <- ggplot(plot_solver,aes(x=name,round(value,2),fill=variable,label=round(value,2)))+ geom_ba

我使用ggplot2绘制了以下条形图

我们可以观察到,x轴文本没有与x轴对齐,而是居中对齐。如何使所有x轴文本与x轴对齐? 我已尝试更改中讨论的
axis.text.x=element\u text(angle=90,vjust=1,hjust=1)
中的值,但无效

用于打印的代码如下所示:

 p <- ggplot(plot_solver,aes(x=name,round(value,2),fill=variable,label=round(value,2)))+ 
    geom_bar(stat="identity",width= 0.7)+
    theme_bw()+geom_text(size = 1, position = position_stack(vjust = 0.5))

    p + theme(legend.position=c(.3,0.85),legend.title = element_blank(),
    legend.text=element_text(size=8),legend.direction = 'horizontal',
    axis.title.y = element_text(size = 8,face = "bold"),
    axis.text.x = element_text(angle = 90, vjust = 1, hjust=1),
    axis.text.y = element_text(size = 9),axis.title.x=element_blank() )+
    guides(fill=guide_legend(title="Formats"))+
    scale_fill_manual(values=rainbow(4),labels=c("X ","Y  ","Z ","U "))+ 
    guides(fill=guide_legend(keywidth=0.2,keyheight=0.1,default.unit="inch",nrow=2))+
    ylab("Speedup")+theme(plot.margin=unit(c(1.0,0.6,0.6,0),"mm"))+ 
    theme(legend.key = element_blank())+
    theme(legend.background = element_rect(colour = "black"))+
    theme(panel.border = element_rect(colour = "black"))

name
变量有空格

library(stringr)    
df$name <- str_replace_all(df$name, "\\s", '')
库(stringr)

df$name可能与我不知道怎么会错过它的副本。可能是因为View()没有显示whitespaces@Stormvirux是的,View()在RStudio中不显示空白。我看不出
View()
是如何工作的,也许它会自动删除空白。
library(stringr)    
df$name <- str_replace_all(df$name, "\\s", '')