我正在使用ggplot制作一个图表,其中x轴标签包含不同蛋白质的名称。由于某些名称过长,标签变得过大,导致很难看到整个图表。除了“打印”更大的图表外,有没有减少x轴标签中字符数量的方法?以下是一个示例,展示了我的问题:
library(ggplot2)
dat <- mtcars
# Make the x-axis labels very long for this example
dat$car <- paste0(rownames(mtcars),rownames(mtcars),rownames(mtcars),rownames(mtcars))
ggplot(dat, aes (x=car,y=hp)) +
geom_bar(stat ="identity", fill="#009E73",colour="black") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
我希望将标签从以下形式转换为另一种形式:Thisisaveryveryveryloooooongprotein
到这里
Thisisavery[...]
为了使我的图表始终可见