Home > other >  how do you specify the x axis in ggplot2 histogram?
how do you specify the x axis in ggplot2 histogram?

Time:12-18

I have the following code to plot a histogram using ggplot2.

ggplot(data = plot, aes(x = total_Amg)) 
  geom_histogram(binwidth = 1, colour = "black", fill = "white")  
  facet_wrap(~ gentamicin) 

How can I specify what numbers are shown on the x axis of the resulting graph, i.e. show 0 to 8, rather than showing those that was automatically generated (see below)?

enter image description here

CodePudding user response:

scale_x_continuous(breaks=0:8) should do the trick

CodePudding user response:

Try adding:

  scale_x_continuous(breaks = 0:8, labels = 0:8)
  • Related