无法适应ggplot中的标签

时间:2017-10-21 08:09:27

标签: r ggplot2 image-resizing

我一直试图缩小图表的大小,因为显着性水平不适合。我尝试过较小的标签尺寸或保存不同的宽度和高度。但是,它没有奏效。有谁知道我怎么能很好地适应这个情节?

我的数据:

- Strain    ODMeas
- S. cerevisiae 2513347767
* S. cerevisiae 2180495141
- S. cerevisiae 2573887734
- L. planatrum  4683416658
- L. planatrum  4633138762
- L. planatrum  3976069017
- L. brevis 4337615408
- L. brevis 3999104478
- L. brevis 4160172507
- L. cassei 4801992910
- L. cassei 5772691076
- L. cassei 5240730493
- L. rossiae    5672433597
- L. rossiae    5762600000
- L. rossiae    5534746544
- A. malorum    4922400000
- A. malorum    4883018043
- A. malorum    4321365731

我的代码:

library(ggplot2)
library(plotrix)
library(dplyr)
library(multcompView)
library(multcomp)
library(agricolae)

mydata=read.csv('OD.csv')

levels(mydata$Strain)
data$Strain=ordered(mydata$Strain, levels=c("S.cerevisiae","L.plantarum","L.brevis","L.cassei","L.rossiae","A.malorum"))

data2= group_by(mydata, Strain) %>% summarise(
count = n(),
mean2 = mean(ODMeas, na.rm = TRUE),
sd2 = sd(ODMeas, na.rm = TRUE))

ANOVA=aov(ODMeas ~ Strain, data = mydata)
myTukey=TukeyHSD(x=ANOVA, conf.level = 0.95, return=TRUE)

comparison = HSD.test(ANOVA, "Strain", group=TRUE)
groups1 <- as.vector(comparison$groups)

ggplot(data2,aes(x=data2$Strain, y=data2$mean2, width=.45)) + 
geom_bar(position="dodge",stat="identity", colour = "black") + 
theme_classic() +
geom_errorbar(aes(ymin=data2$mean2, ymax=data2$mean2 + data2$sd2)) +
geom_text(aes(label=groups1$groups), hjust=-2)+ coord_flip() +
theme(axis.text.x = element_text(size=8,vjust=0.55),
    axis.title.y=element_text(size=8,angle=90),
    title = element_text(size=8, face='bold', hjust=0.5))+
labs(x="Microbial Strains", y = "Cells/g")

ggsave("OD4.png", dpi = 600, width = 3.5, height = 3, units = "in")

来自Tukey HSD测试的显着性水平的平均值 Fig

0 个答案:

没有答案