How to assigning distinct line color for graph?

Hi all, I wanted to have a distinct color of my lines but instead I GOT all the same colored blue.

library(reshape2)
library(wesanderson)

library(rstatix)
library(ggpubr)
library(plyr)
library(datarium)
library(summariser)
library(ggrepel)



#C10

LC10run123 <- read.csv("~/R/Data Analysis/MSc ARTs/Summary/March 2022/lachrymansC10RawPur.csv", stringsAsFactors=TRUE)

mutatedata <- LC10run123 %>% mutate_at(vars("con", "bgrowth", "time", "Purification"), factor)

mutatedata2 <- melt(mutatedata, id.vars=c("con","bgrowth","time", "Purification"),
                    measure.vars="bgrowth")

mutatedata3 <- aggregate(bgrowth ~ con + time + Purification, LC10run123, mean)
# mutatedata3 <- aggregate(bgrowth~ con + time + Purification, LC10run123, sd)

str(mutatedata3)

# fit <- lm(bgrowth~time*con*Purification,data= mutatedata3)
# summary(fit)

ggplot(mutatedata3, 
       aes(x = time, y = bgrowth, group  = con, hue=con))+
      # aes(x = time, y = bgrowth, group  = con))+
  geom_point()+
  # geom_text(data = filter(mutatedata3, time == max(time)),
  #           aes(label = con),
  #           hjust = 0, nudge_x = 3.0) +
  # geom_smooth(formula = y~x+ I(x^2), method=lm , se=FALSE, show.legend = TRUE, aes(color= "red", fill="#69b3a1")) +
  # geom_smooth(formula = y~log(x), method='loess' , se=TRUE, show.legend = TRUE, aes(color= "red", fill="#69b3a1")) +
  geom_smooth(formula = y~x, method=loess , se=TRUE, show.legend = TRUE, span=0.5) +
  # geom_smooth(formula = y~x+I(x^2), method=loess, se=FALSE, show.legend = TRUE, span=0.5) +
  
  stat_smooth()+
  # geom_smooth(formula = y~x+ I(x^2), method=lm , se=FALSE, show.legend = TRUE, aes(color= "red", fill="#69b3a1")) +
  # geom_smooth(formula = y~x+ I(x^2), method=lm , color="red", fill="#69b3a2", se=FALSE, show.legend = TRUE) +
  # annotate("text", label = "y~x", size = 4, x = 96, y = ave(bgrowth))+
  annotate("text",x=72,y=0.5,hjust=0,label="y~x", size=4)+
  
  facet_wrap(~Purification) +
  theme_bw()+
  theme(panel.border = element_blank(),
        panel.background = element_rect(color = "black"),
        strip.background = element_rect(fill = "darkgray"),
        strip.text.x = element_text(face="bold", size=12),
        legend.title=element_text(face="bold"),
        axis.text=element_text(size=12,colour = "black"),
        axis.title.y =element_text(size=12,face="bold", margin = margin(r=7)),
        axis.title.x =element_text(size=12,face="bold", margin = margin(t=7)),
        strip.text = element_text(size=12, face="bold", color="black"))+
  # scale_color_manual(values = c("0" = "black", "5" = "red", "10"= "purple",
  #                               "25"="blue", "50"= "green", "100"= "orange",
  #                               "250"= "skyblue", "500"="maroon", "750"="violet"))+
  scale_y_continuous(breaks = seq(0.1,1, by=0.1)) +
  scale_x_continuous(breaks= seq(0,96, by=24))+
  # scale_color_discrete()+
  
  
  xlab("Time(Hours)") +
  ylab("Bacterial growth (595 nm wavelength)")

Instead of using a csv file for the reprex (for which you have to enclose the file plus it takes several steps to execute the code in another's machine), it is usually a better practice to include representative data and paste it in the code using dput. That will ensure the code and data are both available together for anyone to be able to execute in their machine. Note: reprentative data is the bare minimum data to replicate the problem.

Hallo Sanjmeh, thanks for the comment and suggestions.

I really do not know much about how to insert the file data but maybe I can send it to you here like uploading it, is it fit?

time con bgrowth Purification RhlType
0 0 0.054077777 RAW C14
0 0 0.0685 RAW C14
0 0 0.026744443 RAW C14
0 5 0.053544443 RAW C14
0 5 0.068288892 RAW C14
0 5 0.025900001 RAW C14
0 10 0.050799998 RAW C14
0 10 0.06631111 RAW C14
0 10 0.02448889 RAW C14
0 25 0.053177776 RAW C14
0 25 0.067511109 RAW C14
0 25 0.025344443 RAW C14
0 50 0.054233333 RAW C14
0 50 0.071433335 RAW C14
0 50 0.0257 RAW C14
0 100 0.055088885 RAW C14
0 100 0.071733333 RAW C14
0 100 0.026511111 RAW C14
0 250 0.05564444 RAW C14
0 250 0.067944443 RAW C14
0 250 0.026433334 RAW C14
0 500 0.058188888 RAW C14
0 500 0.068177779 RAW C14
0 500 0.025955555 RAW C14
0 750 0.056088885 RAW C14
0 750 0.069733334 RAW C14
0 750 0.026511111 RAW C14
24 0 0.635544441 RAW C14
24 0 0.514433345 RAW C14
24 0 0.490211104 RAW C14
24 5 0.854355555 RAW C14
24 5 0.704055555 RAW C14
24 5 0.699011101 RAW C14
24 10 0.859155551 RAW C14
24 10 0.727388886 RAW C14
24 10 0.717944437 RAW C14
24 25 0.873033333 RAW C14
24 25 0.733611114 RAW C14
24 25 0.741766666 RAW C14
24 50 0.875222214 RAW C14
24 50 0.726455557 RAW C14
24 50 0.742722214 RAW C14
24 100 0.87636667 RAW C14
24 100 0.73375555 RAW C14
24 100 0.753133338 RAW C14
24 250 0.874999995 RAW C14
24 250 0.727300002 RAW C14
24 250 0.749855566 RAW C14
24 500 0.869066664 RAW C14
24 500 0.743155553 RAW C14
24 500 0.755233328 RAW C14
24 750 0.861655548 RAW C14
24 750 0.746566667 RAW C14
24 750 0.740066675 RAW C14
48 0 0.745566663 RAW C14
48 0 0.672088886 RAW C14
48 0 0.539477775 RAW C14
48 5 0.916099995 RAW C14
48 5 0.729022223 RAW C14
48 5 0.726077765 RAW C14
48 10 0.89887777 RAW C14
48 10 0.708488893 RAW C14
48 10 0.688611113 RAW C14
48 25 0.904488885 RAW C14
48 25 0.707955564 RAW C14
48 25 0.746277766 RAW C14
48 50 0.898722221 RAW C14
48 50 0.718977787 RAW C14
48 50 0.695800003 RAW C14
48 100 0.907077779 RAW C14
48 100 0.720633333 RAW C14
48 100 0.740911096 RAW C14
48 250 0.909433328 RAW C14
48 250 0.712455556 RAW C14
48 250 0.722533342 RAW C14
48 500 0.908500006 RAW C14
48 500 0.722133343 RAW C14
48 500 0.733944452 RAW C14
48 750 0.905811114 RAW C14
48 750 0.748233337 RAW C14
48 750 0.735788872 RAW C14
72 0 0.763200004 RAW C14
72 0 0.654966658 RAW C14
72 0 0.506355549 RAW C14
72 5 0.882088879 RAW C14
72 5 0.724333325 RAW C14
72 5 0.578622227 RAW C14
72 10 0.864133331 RAW C14
72 10 0.696800006 RAW C14
72 10 0.573511109 RAW C14
72 25 0.879533343 RAW C14
72 25 0.701866659 RAW C14
72 25 0.591622225 RAW C14
72 50 0.875988887 RAW C14
72 50 0.71194444 RAW C14
72 50 0.591133321 RAW C14
72 100 0.867644461 RAW C14
72 100 0.721133337 RAW C14
72 100 0.596522217 RAW C14
72 250 0.870155559 RAW C14
72 250 0.716477784 RAW C14
72 250 0.590666663 RAW C14
72 500 0.876722222 RAW C14
72 500 0.725299993 RAW C14
72 500 0.589766666 RAW C14
72 750 0.87406667 RAW C14
72 750 0.749733321 RAW C14
72 750 0.598522224 RAW C14
96 0 0.774755555 RAW C14
96 0 0.650211121 RAW C14
96 0 0.489066659 RAW C14
96 5 0.858644443 RAW C14
96 5 0.756199994 RAW C14
96 5 0.555111109 RAW C14
96 10 0.834744444 RAW C14
96 10 0.724644447 RAW C14
96 10 0.54858889 RAW C14
96 25 0.84894445 RAW C14
96 25 0.713277775 RAW C14
96 25 0.571344434 RAW C14
96 50 0.838288881 RAW C14
96 50 0.711677781 RAW C14
96 50 0.567144432 RAW C14
96 100 0.843344441 RAW C14
96 100 0.712166665 RAW C14
96 100 0.574666657 RAW C14
96 250 0.832666666 RAW C14
96 250 0.703177782 RAW C14
96 250 0.57164443 RAW C14
96 500 0.832288885 RAW C14
96 500 0.710699994 RAW C14
96 500 0.569555546 RAW C14
96 750 0.828622219 RAW C14
96 750 0.755966662 RAW C14
96 750 0.570777772 RAW C14
0 0 0.054077777 PUR C14
0 0 0.0685 PUR C14
0 0 0.026744443 PUR C14
0 5 0.051088887 PUR C14
0 5 0.071566667 PUR C14
0 5 0.028622222 PUR C14
0 10 0.051411111 PUR C14
0 10 0.070766665 PUR C14
0 10 0.025388888 PUR C14
0 25 0.050644443 PUR C14
0 25 0.067944443 PUR C14
0 25 0.026144444 PUR C14
0 50 0.053177775 PUR C14
0 50 0.068122222 PUR C14
0 50 0.025433333 PUR C14
0 100 0.052988886 PUR C14
0 100 0.066388886 PUR C14
0 100 0.025122223 PUR C14
0 250 0.054533332 PUR C14
0 250 0.065788891 PUR C14
0 250 0.028088888 PUR C14
0 500 0.056088887 PUR C14
0 500 0.066511112 PUR C14
0 500 0.02512222 PUR C14
0 750 0.052677778 PUR C14
0 750 0.070700002 PUR C14
0 750 0.026266667 PUR C14
24 0 0.635544441 PUR C14
24 0 0.514433345 PUR C14
24 0 0.490211104 PUR C14
24 5 0.858433341 PUR C14
24 5 0.72485555 PUR C14
24 5 0.741488881 PUR C14
24 10 0.870144448 PUR C14
24 10 0.751644453 PUR C14
24 10 0.751744457 PUR C14
24 25 0.870411106 PUR C14
24 25 0.737722225 PUR C14
24 25 0.764088896 PUR C14
24 50 0.873577782 PUR C14
24 50 0.716822228 PUR C14
24 50 0.756466668 PUR C14
24 100 0.878266667 PUR C14
24 100 0.728988893 PUR C14
24 100 0.753377783 PUR C14
24 250 0.87857777 PUR C14
24 250 0.719355551 PUR C14
24 250 0.762000005 PUR C14
24 500 0.873522217 PUR C14
24 500 0.715288885 PUR C14
24 500 0.747466671 PUR C14
24 750 0.867288883 PUR C14
24 750 0.749999994 PUR C14
24 750 0.761455557 PUR C14
48 0 0.745566663 PUR C14
48 0 0.672088886 PUR C14
48 0 0.539477775 PUR C14
48 5 0.905388882 PUR C14
48 5 0.728644442 PUR C14
48 5 0.766877787 PUR C14
48 10 0.904688885 PUR C14
48 10 0.719555548 PUR C14
48 10 0.73775554 PUR C14
48 25 0.893633329 PUR C14
48 25 0.711277781 PUR C14
48 25 0.607800004 PUR C14
48 50 0.896177785 PUR C14
48 50 0.697033344 PUR C14
48 50 0.66645555 PUR C14
48 100 0.904966669 PUR C14
48 100 0.703944443 PUR C14
48 100 0.670399987 PUR C14
48 250 0.903588894 PUR C14
48 250 0.681866664 PUR C14
48 250 0.650077777 PUR C14
48 500 0.898488883 PUR C14
48 500 0.678055556 PUR C14
48 500 0.635422213 PUR C14
48 750 0.894688888 PUR C14
48 750 0.725622215 PUR C14
48 750 0.70873335 PUR C14
72 0 0.763200004 PUR C14
72 0 0.654966658 PUR C14
72 0 0.506355549 PUR C14
72 5 0.859622219 PUR C14
72 5 0.705811102 PUR C14
72 5 0.597322224 PUR C14
72 10 0.864322224 PUR C14
72 10 0.697311109 PUR C14
72 10 0.593388887 PUR C14
72 25 0.854033343 PUR C14
72 25 0.693455556 PUR C14
72 25 0.592122215 PUR C14
72 50 0.850200003 PUR C14
72 50 0.683333343 PUR C14
72 50 0.588788892 PUR C14
72 100 0.853500001 PUR C14
72 100 0.692877769 PUR C14
72 100 0.585011103 PUR C14
72 250 0.855922215 PUR C14
72 250 0.682633326 PUR C14
72 250 0.604422217 PUR C14
72 500 0.857988887 PUR C14
72 500 0.680855552 PUR C14
72 500 0.584433329 PUR C14
72 750 0.852044442 PUR C14
72 750 0.729500002 PUR C14
72 750 0.599611109 PUR C14
96 0 0.774755555 PUR C14
96 0 0.650211121 PUR C14
96 0 0.489066659 PUR C14
96 5 0.846777774 PUR C14
96 5 0.708088893 PUR C14
96 5 0.570877769 PUR C14
96 10 0.846611107 PUR C14
96 10 0.693044449 PUR C14
96 10 0.570133327 PUR C14
96 25 0.848066665 PUR C14
96 25 0.683800007 PUR C14
96 25 0.569522227 PUR C14
96 50 0.835011109 PUR C14
96 50 0.673044435 PUR C14
96 50 0.56244444 PUR C14
96 100 0.82808889 PUR C14
96 100 0.679744447 PUR C14
96 100 0.561466666 PUR C14
96 250 0.823666663 PUR C14
96 250 0.666788888 PUR C14
96 250 0.578866666 PUR C14
96 500 0.816311099 PUR C14
96 500 0.675900007 PUR C14
96 500 0.562899998 PUR C14
96 750 0.815122211 PUR C14
96 750 0.732355553 PUR C14
96 750 0.574244445 PUR C14

I hope this will solve my problem.

Thank you so much.

All the best, Rex.

okay, it works with the table but as indicated before it's better with dput()

dput(LC10run123) 
LC10run123 = structure(list(time = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 
24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 
48, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 96, 96, 96, 96, 
96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
96, 96, 96, 96, 96, 96, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 
24, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, 
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 
48, 48, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 96, 96, 96, 
96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
96, 96, 96, 96, 96, 96, 96, 96), con = c(0, 0, 0, 5, 5, 5, 10, 
10, 10, 25, 25, 25, 50, 50, 50, 100, 100, 100, 250, 250, 250, 
500, 500, 500, 750, 750, 750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 
25, 25, 50, 50, 50, 100, 100, 100, 250, 250, 250, 500, 500, 500, 
750, 750, 750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 25, 25, 50, 
50, 50, 100, 100, 100, 250, 250, 250, 500, 500, 500, 750, 750, 
750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 25, 25, 50, 50, 50, 100, 
100, 100, 250, 250, 250, 500, 500, 500, 750, 750, 750, 0, 0, 
0, 5, 5, 5, 10, 10, 10, 25, 25, 25, 50, 50, 50, 100, 100, 100, 
250, 250, 250, 500, 500, 500, 750, 750, 750, 0, 0, 0, 5, 5, 5, 
10, 10, 10, 25, 25, 25, 50, 50, 50, 100, 100, 100, 250, 250, 
250, 500, 500, 500, 750, 750, 750, 0, 0, 0, 5, 5, 5, 10, 10, 
10, 25, 25, 25, 50, 50, 50, 100, 100, 100, 250, 250, 250, 500, 
500, 500, 750, 750, 750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 25, 
25, 50, 50, 50, 100, 100, 100, 250, 250, 250, 500, 500, 500, 
750, 750, 750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 25, 25, 50, 
50, 50, 100, 100, 100, 250, 250, 250, 500, 500, 500, 750, 750, 
750, 0, 0, 0, 5, 5, 5, 10, 10, 10, 25, 25, 25, 50, 50, 50, 100, 
100, 100, 250, 250, 250, 500, 500, 500, 750, 750, 750), bgrowth = c(0.054077777, 
0.0685, 0.026744443, 0.053544443, 0.068288892, 0.025900001, 0.050799998, 
0.06631111, 0.02448889, 0.053177776, 0.067511109, 0.025344443, 
0.054233333, 0.071433335, 0.0257, 0.055088885, 0.071733333, 0.026511111, 
0.05564444, 0.067944443, 0.026433334, 0.058188888, 0.068177779, 
0.025955555, 0.056088885, 0.069733334, 0.026511111, 0.635544441, 
0.514433345, 0.490211104, 0.854355555, 0.704055555, 0.699011101, 
0.859155551, 0.727388886, 0.717944437, 0.873033333, 0.733611114, 
0.741766666, 0.875222214, 0.726455557, 0.742722214, 0.87636667, 
0.73375555, 0.753133338, 0.874999995, 0.727300002, 0.749855566, 
0.869066664, 0.743155553, 0.755233328, 0.861655548, 0.746566667, 
0.740066675, 0.745566663, 0.672088886, 0.539477775, 0.916099995, 
0.729022223, 0.726077765, 0.89887777, 0.708488893, 0.688611113, 
0.904488885, 0.707955564, 0.746277766, 0.898722221, 0.718977787, 
0.695800003, 0.907077779, 0.720633333, 0.740911096, 0.909433328, 
0.712455556, 0.722533342, 0.908500006, 0.722133343, 0.733944452, 
0.905811114, 0.748233337, 0.735788872, 0.763200004, 0.654966658, 
0.506355549, 0.882088879, 0.724333325, 0.578622227, 0.864133331, 
0.696800006, 0.573511109, 0.879533343, 0.701866659, 0.591622225, 
0.875988887, 0.71194444, 0.591133321, 0.867644461, 0.721133337, 
0.596522217, 0.870155559, 0.716477784, 0.590666663, 0.876722222, 
0.725299993, 0.589766666, 0.87406667, 0.749733321, 0.598522224, 
0.774755555, 0.650211121, 0.489066659, 0.858644443, 0.756199994, 
0.555111109, 0.834744444, 0.724644447, 0.54858889, 0.84894445, 
0.713277775, 0.571344434, 0.838288881, 0.711677781, 0.567144432, 
0.843344441, 0.712166665, 0.574666657, 0.832666666, 0.703177782, 
0.57164443, 0.832288885, 0.710699994, 0.569555546, 0.828622219, 
0.755966662, 0.570777772, 0.054077777, 0.0685, 0.026744443, 0.051088887, 
0.071566667, 0.028622222, 0.051411111, 0.070766665, 0.025388888, 
0.050644443, 0.067944443, 0.026144444, 0.053177775, 0.068122222, 
0.025433333, 0.052988886, 0.066388886, 0.025122223, 0.054533332, 
0.065788891, 0.028088888, 0.056088887, 0.066511112, 0.02512222, 
0.052677778, 0.070700002, 0.026266667, 0.635544441, 0.514433345, 
0.490211104, 0.858433341, 0.72485555, 0.741488881, 0.870144448, 
0.751644453, 0.751744457, 0.870411106, 0.737722225, 0.764088896, 
0.873577782, 0.716822228, 0.756466668, 0.878266667, 0.728988893, 
0.753377783, 0.87857777, 0.719355551, 0.762000005, 0.873522217, 
0.715288885, 0.747466671, 0.867288883, 0.749999994, 0.761455557, 
0.745566663, 0.672088886, 0.539477775, 0.905388882, 0.728644442, 
0.766877787, 0.904688885, 0.719555548, 0.73775554, 0.893633329, 
0.711277781, 0.607800004, 0.896177785, 0.697033344, 0.66645555, 
0.904966669, 0.703944443, 0.670399987, 0.903588894, 0.681866664, 
0.650077777, 0.898488883, 0.678055556, 0.635422213, 0.894688888, 
0.725622215, 0.70873335, 0.763200004, 0.654966658, 0.506355549, 
0.859622219, 0.705811102, 0.597322224, 0.864322224, 0.697311109, 
0.593388887, 0.854033343, 0.693455556, 0.592122215, 0.850200003, 
0.683333343, 0.588788892, 0.853500001, 0.692877769, 0.585011103, 
0.855922215, 0.682633326, 0.604422217, 0.857988887, 0.680855552, 
0.584433329, 0.852044442, 0.729500002, 0.599611109, 0.774755555, 
0.650211121, 0.489066659, 0.846777774, 0.708088893, 0.570877769, 
0.846611107, 0.693044449, 0.570133327, 0.848066665, 0.683800007, 
0.569522227, 0.835011109, 0.673044435, 0.56244444, 0.82808889, 
0.679744447, 0.561466666, 0.823666663, 0.666788888, 0.578866666, 
0.816311099, 0.675900007, 0.562899998, 0.815122211, 0.732355553, 
0.574244445), Purification = c("RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", "RAW", 
"RAW", "RAW", "RAW", "RAW", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", "PUR", 
"PUR", "PUR", "PUR", "PUR"), RhlType = c("C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", "C14", 
"C14", "C14", "C14", "C14", "C14", "C14")), row.names = c(NA, 
-270L), class = c("tbl_df", "tbl", "data.frame"))

This can be copied directly into R.

Also your mutatedata and mutatedata2 aren't needed for your example so you can leave this out in the question.

You were nearly there, you just needed to define the colours with "colour = as.factor(con)", the "as.factor" is needed because these are numbers and are interpreted as numbers.

ggplot(mutatedata3, 
       aes(x = time, y = bgrowth,
   #        fill = as.factor(con),
           colour = as.factor(con)  )) +
  geom_point() +
  geom_smooth(formula = y~x, method=loess , 
              se= FALSE, 
              show.legend = TRUE, span=0.5) +
  annotate("text",x=72, y=0.5, hjust=0, label="y~x", size=4)+
  facet_wrap(~Purification) +
  theme_bw()+
  theme(panel.border = element_blank(),
        panel.background = element_rect(color = "black"),
        strip.background = element_rect(fill = "darkgray"),
        strip.text.x = element_text(face="bold", size=12),
        legend.title=element_text(face="bold"),
        axis.text=element_text(size=12,colour = "black"),
        axis.title.y =element_text(size=12,face="bold", margin = margin(r=7)),
        axis.title.x =element_text(size=12,face="bold", margin = margin(t=7)),
        strip.text = element_text(size=12, face="bold", color="black"))+
  scale_color_manual(name = "Concentration",
                     values = c("0" = "black", "5" = "red", "10"= "purple",
                               "25"="blue", "50"= "green", "100"= "orange",
                               "250"= "skyblue", "500"="maroon", "750"="violet"),
                     aesthetics = "colour" ) + 
#   or for using with se = TRUE:
#                     aesthetics = c("fill", "colour" ))+
  scale_y_continuous(breaks = seq(0.1,1, by=0.1)) +
  scale_x_continuous(breaks= seq(0,96, by=24))

In the geom_smooth the se can be set to false, with the average value there isn't much to show anyway. If you want to keep it you also need to define the fill values (commented out in the example above).

This however might be more interesting when showing the individual values (that have quite big spreads)

ggplot(LC10run123, 
       aes(x = time, y = bgrowth,
           fill = as.factor(con),
           colour = as.factor(con)  )) +
  geom_point() +
  geom_smooth(formula = y~x, method=loess , 
              se= TRUE, 
              show.legend = TRUE, span=0.5) +
  annotate("text",x=72, y=0.5, hjust=0, label="y~x", size=4)+
  facet_grid(Purification ~ con) +
  theme_bw()+
  theme(legend.position = "none",  # hide the legend here
        panel.border = element_blank(),
        panel.background = element_rect(color = "black"),
        strip.background = element_rect(fill = "darkgray"),
        strip.text.x = element_text(face="bold", size=12),
        legend.title=element_text(face="bold"),
        axis.text=element_text(size=12,colour = "black"),
        axis.title.y =element_text(size=12,face="bold", margin = margin(r=7)),
        axis.title.x =element_text(size=12,face="bold", margin = margin(t=7)),
        strip.text = element_text(size=12, face="bold", color="black"))+
  scale_color_manual(name = "Concentration",
                     values = c("0" = "black", "5" = "red", "10"= "purple",
                                "25"="blue", "50"= "green", "100"= "orange",
                                "250"= "skyblue", "500"="maroon", "750"="violet"),
                       aesthetics = c("fill", "colour" ))+
  scale_y_continuous(breaks = seq(0.1,1, by=0.1)) +
  scale_x_continuous(breaks= seq(0,96, by=24))

1 Like

Thank you so much @Matthias and Sanjmay. I cannot mention a lot because I am a new user here. I am so much grateful for this. Hopefully, I could continue with the statistical analysis after this.

Using the same data above, I wanted to make a bar or boxplot just all for the time 96, removing all outliers. Please help me, here is my code:

#CFU FOR MARCH 24 2022

CFU <- read.csv("~/R/Data Analysis/MSc ARTs/Summary/March 2022/CFU.csv", header=TRUE, stringsAsFactors=TRUE)
mutatedata3 <- aggregate(CFU5uL ~ treatment, CFU, mean)

boxplot(CFU$CFU5uL, plot=FALSE)$out

outliers <- boxplot(CFU$CFU5uL, plot=FALSE)$out

CFU %>%

group_by(treatment) %>%

shapiro_test(CFU5uL)

fit <- lm(CFU5uL ~ treatment,data= mutatedata3)
summary(fit)

kruskal.test(CFU5ul~treatment, data = CFU)
pairwise.wilcox.test(CFU5ul, treatment, method=p.adjust.methods, paired = TRUE)

x<-CFU
x<- x[-which(x$CFU5ul %in% outliers),]

outlier<-CFU %>%

group_by('treatment') %>%

identify_outliers('CFU5uL')

eliminated<- subset(CFU, CFU~'CFU5uL' > (Q[1] - 1.5iqr) & CFU~'CFU5uL' < (Q[2]+1.5iqr))

ggplot(CFU,
aes(x = treatment, y =CFU5uL,
# fill = as.factor(treatment),
colour = as.factor(treatment) )) +
geom_point() +

geom_smooth(formula = y~x, method=loess ,

se= FALSE,

show.legend = TRUE, span=0.5) +

annotate("text",x=72, y=0.5, hjust=0, label="y~x", size=4)+

facet_wrap(~Purification) +

geom_jitter()+

theme_prism()+
theme(panel.border = element_blank(),
panel.background = element_rect(color = "black"),
strip.background = element_rect(fill = "darkgray"),
strip.text.x = element_text(face="bold", size=12),
legend.title=element_text(face="bold"),
axis.text=element_text(size=12,colour = "black"),
axis.title.y =element_text(size=12,face="bold", margin = margin(r=7)),
axis.title.x =element_text(size=12,face="bold", margin = margin(t=7)),
strip.text = element_text(size=12, face="bold", color="black"))+

scale_color_manual(name = "Concentration",

values = c("0" = "black", "5" = "red", "10"= "purple",

"25"="blue", "50"= "green", "100"= "orange",

"250"= "skyblue", "500"="maroon", "750"="violet"),

aesthetics = "colour" ) +

or for using with se = TRUE:

aesthetics = c("fill", "colour" ))+

scale_y_continuous(breaks = seq(0,100, by=50)) +

scale_x_continuous(breaks= seq(0,96, by=24))

xlab("treatment") +

ylab("CFU/5ul")+
labs(color= "Treatment")+
geom_boxplot()