I am making a series of bar plots using ggplot, the plots are of (for e.g) number of nests on a given day for a number of different years. I can make the plots no problem and use cowplot to arrange them in one figure, however, I want them all to be comparable and start on the same day. This is an example plot and here are the data.
dput(ringday2015) structure(list(Var1 = structure(1:37, .Label = c("42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "69", "70", "72", "73", "74", "79", "83", "85", "88", "89", "91"), class = "factor"), Freq = c(1L, 1L, 1L, 2L, 5L, 6L, 7L, 12L, 15L, 22L, 12L, 19L, 17L, 26L, 16L, 17L, 13L, 13L, 13L, 9L, 1L, 5L, 4L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), class = "data.frame", row.names = c(NA, -37L ))
This plot starts on day 42, but for the next plot it starts at day 33 and then another at day 31. SO I wanted to have them all start on day 30. I've tried using scale_x_continous, scale_x_discrete, xlim and any other suggestion I've seen but none seem to have any effect on the plot, i.e. the x axis does not change or changes so much that the plot is useless. What am I missing?
Code:
ringdayplot2015<- ggplot(data = ringday2015, aes(Var1, Freq )) + geom_bar(stat = "identity") +
xlab("April Day (days after April 1st)") + ylab("No. of nests") + ggtitle("No. of nests ringed 2015")
Above is the code I've used to make the plot included
dput()function. - Ricardo Semião e Castrodput()you posted,Var1is a factor, shouldn't it be a numeric? - Ricardo Semião e Castroringday2015$Var1<- as.numeric(ringday2015$Var1)dput(ringday2015$Var1) c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37) - McMahok