library(grid)
library(dplyr)
library(ggplot2)
library(beeswarm)

#set the working directory
setwd("C:/Users/xx")

#save data in d
d <- "C:/Users/xx.csv"

#read d and store data in ds
ds <- read.table(d, header = TRUE, sep = ";", stringsAsFactors = FALSE)

#creates plot using dataset saved in p
p <- ggplot(ds, aes(Strain, RFU), color = Strain)

p + geom_boxplot(width=0.7, outlier.shape = 1) + #Add a boxplot
  stat_summary(fun.y=mean, colour="black", geom="point", shape=8, size=2,show.legend = FALSE) + #Add average and symbol form
  scale_y_continuous(limits = c(0, 40000), breaks=c(0, 10000, 20000, 30000 , 40000)) + #Adjust y-axis scale
   ylab("Supernatant fluorescence") + # changes y-axis title
   xlab("Strain") + # changes x-axis title
   theme(axis.text.y   = element_text(colour = "black", size=11),  #Controls colors and graph form 
        axis.text.x   = element_text(margin=margin(10,0,0,0), colour = "black", size=11),
        axis.title.y  = element_text(margin=margin(0,20,0,0), size=14),
        axis.title.x  = element_text(margin=margin(20,0,0,0), size=14),
        panel.background = element_blank(),
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        axis.line = element_line(size = 0.2, colour = "black"),
        panel.border = element_rect(colour = "black", fill=NA, size=NA),
        axis.text=element_text(size=13), 
        axis.title=element_text(size=14,face="bold"))
 
  
  #Creates a Tiff file
  tiff(filename = "C:/Users/yy.tiff", #define file name
       width = 861, height = 548, units = "px", pointsize = 12) +

    #save data plot in tiff file  
    ggsave("test.tiff",  #define file name
           plot = last_plot(), 
           device = NULL, 
           path = NULL, 
           scale = 1, 
           width = NA, 
           height = NA, 
           dpi = 300, 
           limitsize = TRUE)
