1

With this code

f9 <- ggplot() + 
  geom_smooth(data = pred.dat, mapping = aes(x = month, y = fit)) +
  theme_classic() + 
  theme(axis.title.x = element_text(face = "bold", size = 14), 
        axis.title.y = element_text(face = "bold", size = 14), 
        axis.text.x = element_text(size = 12), 
        axis.text.y = element_text(size = 12)) +
  scale_x_continuous(breaks = c(3, 6, 9), 
                     labels = c("March", "June", "September")) +
  scale_y_continuous(breaks = c(0, 1, 2)) +
  xlab("Month") + 
  ylab("Predicted number of RHDV releases"); x11(); f9

I produce this figure Figure 1

You will notice that in the above code I have tried to set the y axis breaks using scale_y_continuous(breaks = c(0, 1, 2)). However, this has not worked.

I read here that I need to include a call to limits = as follows scale_y_continuous(breaks = c(0, 1, 2), limits = c(0, 2)).

If I re-run my figure code with the new call to y axis limits it completely changes my figure. What am I doing wrong? Any help would be much appreciated. I am wanting to produce the same figure as the top figure in this post but with a y axis that ranges from 0-2.

f9 <- ggplot() + 
  geom_smooth(data = pred.dat, mapping = aes(x = month, y = fit)) +
  theme_classic() + 
  theme(axis.title.x = element_text(face = "bold", size = 14), 
        axis.title.y = element_text(face = "bold", size = 14), 
        axis.text.x = element_text(size = 12), 
        axis.text.y = element_text(size = 12)) +
  scale_x_continuous(breaks = c(3, 6, 9), 
                     labels = c("March", "June", "September")) +
  scale_y_continuous(breaks = c(0, 1, 2), limits = c(0, 2)) +
  xlab("Month") + 
  ylab("Predicted number of RHDV releases"); x11(); f9

The above code produces the below figure which is completely different to the first figure. Why and how might I fix this?

Figure 2

Pat Taggart
  • 321
  • 1
  • 9

0 Answers0