How to get rid of NA tick mark in ggplot and make it stop drawing error bar for month that the value is 0?

25 Views Asked by At

I have a 13 month time series from September-September (month of March is no data but included because of the time series aspect)that I am trying to make a bar plot of. I need error bars, and am using geom_errorbar, but I do not want it to draw a line for March. I also am having trouble with the axis ticks. The second September value is always labelled as NA. This is the code that I have.

This is the plot it makes.

bay <- ggplot(stn1, aes(x = factor(Month, level = c("SEP", "OCT", "NOV", "DEC", "JAN", "FEB",
"MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEPTEMBER")), y = Temperature))+
  geom_bar(stat = "identity", position = position_dodge())+
  theme_classic()+
  xlab("Month")+
  ylab("Temperature°C")+
  geom_errorbar(aes(ymin=Temperature-Temperature_sd, ymax=Temperature+Temperature_sd), width=.2,
                position=position_dodge(.9)) 
print(bay)

I tried using scale_x_discrete() to manually change the NA, but it did not work.

0

There are 0 best solutions below