Carrol
Carrol

Reputation: 1285

R ggplot2 - align theme grid with axis tick lines

I have a ggplot2 barchart for which I changed the axis ticks. However, the panel grid is adding additional lines that I do not want. How do I remove them?

My problems:

  1. I only want the vertical grid lines that match the x-axis ticks.

  2. The position dodge preserve is not working correctly due to having a group and a fill.

My code:

ggplot(byyear, aes(x = year, y = count, group = venue, colour = venue, fill = type)) +
  geom_bar(stat = "identity", position=position_dodge(preserve = "single")) +
  
  # BORDER SO I CAN DISTINGUISH THEM
  scale_colour_manual(name = "Venue", values = c("#FFFFFF", "#FFFFFF")) +
  
  # MAKE ALL YEARS APPEAR
  scale_y_continuous(labels = number_format(accuracy = 1)) +
  scale_x_continuous(breaks = unique(byyear$year)) +
  theme(legend.position="bottom",
        axis.text.x = element_text(angle = 90, hjust = 1))

The data is of the structure:

year,venue,type,count
2010,venue1,type1,163
2010,venue1,type2,18
2011,venue1,type1,16
...

The plot that I'm obtaining is the following (I removed the legend on the plot)

enter image description here

Upvotes: 1

Views: 1172

Answers (0)

Related Questions