0

I have been trying to shrink the size of my graph because significance levels don't fit in. I have tried smaller label sizes or saving in different width and height. However, it didn't work well. Does anyone know how can I fit the plot well?

My data:

- 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

My code:

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")

Mean with significance levels from Tukey HSD Test Fig

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Mel
  • 11
  • 5
  • @MarcoSandri I have edited my question with the code and my data, thanks! – Mel Oct 22 '17 at 02:30
  • 1
    Replace `coord_flip()` with `coord_flip(ylim = c(0, 7e+09))` (or some other arbitrarily large limit) to extend the range for your axis. – Z.Lin Oct 22 '17 at 03:12
  • @Z.Lin It worked well! Thank you very much – Mel Oct 23 '17 at 01:06

0 Answers0