Hi! Recently I was trying to re-knit an old Rmd with a graph that made use of scale_x_discrete(), but running the same code now seems to yield a different (buggy) plot. In particular, I've isolated the issue to the inclusion of the limit parameter. Whereas two months ago I had no issue, I can't get the original plots today.
What might be my issue here? I'm wondering whether it has to do with a particular version of ggplot2 I'm using (I just reinstalled the latest via install.packages('tidyverse') to my new machine today). Or are there alternative ways to get the plot I'm aiming for?
Reprex:
library(tidyverse)
beer_states <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-03-31/beer_states.csv')
beer_states %>%
filter(state == "CA") %>%
ggplot(aes(x = year, y = barrels)) +
geom_col() +
scale_x_discrete(limits = 2008:2019)
The columns all scrunch up to the rightmost side of the x-axis.
Expected behavior:
library(tidyverse)
beer_states <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-03-31/beer_states.csv')
beer_states %>%
filter(state == "CA") %>%
ggplot(aes(x = year, y = barrels)) +
geom_col()
I am trying to make a plot similar to the above, except with the x-axis tickmarks at each year between 2008 and 2019 (inclusive).