1

I have have plotted a graph that worked perfectly fine with the script I was using with y=absorbance, dose=x and the diffrent curves represent the time. When I want to change to have time=x and dose representing curves I get the Error: Continuous value supplied to discrete scale.

I do not have any discrete scale set in my script as seen below:

pd <- position_dodge(0.1) 
ggplot(Cell_line_absorbance_summary, aes(x=Time, y=absorbance, colour=Dose, group=Dose)) + 
  geom_errorbar(aes(ymin=absorbance-se, ymax=absorbance+se), colour="black", width=.1, position=pd) +
  geom_line(position=pd) +
  geom_point(position=pd, size=3, shape=21, fill="white") + # 21 is filled circle
  xlab("Time (h)") +
  ylab("Absorbance") +

  scale_colour_hue(name="X-ray exposure",    # Legend label, use darker colors
   breaks=c("0", "2", "4", "6", "8", "10"), #forlater when IC50 available labels=c("24h (IC50 = 13 nM)", "48h (IC50 = 3.3 nM)", "72h (IC50 = 2.5 nM)"),
                   l=40) +                    

ggtitle("HCC38") +
  expand_limits(y=0) +                        
  scale_y_continuous() +      
  scale_x_continuous(limits = c(0,400),breaks=0:400*24) +
  theme_classic() +                          
  theme(legend.justification=c(0,0),
        legend.position=c(0,0))    +          
  scale_color_jco()

I tried to switch the scale_x_continuous to scale_x_discrete (as well as the y which only lead to the same error since all my data is continous.)

Specific pakages I currenlty am running is: Rmisc, ggplot2 & ggsci.

Greatful for any help and advice since I am relativly new to using R.

Daniella
  • 11
  • 2

1 Answers1

1

It looks likeDose is continuous and not discrete. If you change it to a factor it should go fine. Try:

Cell_line_absorbance_summary$Dose <- as.factor(Cell_line_absorbance_summary$Dose)
ricoderks
  • 1,619
  • 9
  • 13
  • Perfect! This was the error and I tried to just put in factor before, but not whole code line that you wrote. Now it looks exactly as I wanted it to do. Thank you so much! – Daniella Dec 11 '19 at 10:19