我试图用ggbarplot函数(ggpubr包)绘制一个水平条形图,这是我到目前为止所做的:
我想改变一些事情。首先,我希望在垂直轴标签之间留出更多空间,因此在某种意义上,条形图必须变得更长。
其次,我希望“负面条形图”的标签是'位于左侧,类似于“正面条形图”的标签。在RHS上。
这是我为现在的图形编写的代码,其中graph_data包含所有数据。
ggbarplot(graph_data, x = "name" , y = "cum_r",
fill = "grp", # change fill color by mpg_level
color = "White", # Set bar border colors to white
palette = c("red", "green"),
sort.val = "asc", # Sort the value in descending order
sort.by.groups = FALSE, # Don't sort inside each group
x.text.angle = 90, # Rotate vertically x axis texts
ylab = "Cumulative return (%)",
xlab = "Keyword",
legend.title = "Return",
rotate = TRUE,
lab.nb.digits = 2,
ggtheme = theme_classic(),
label=TRUE, lab.pos = "out", lab.col = "black",
lab.size=2,
lab.vjust = 0.5,
lab.hjust = -0.5)