R ggplot2-将主题网格与轴刻度线对齐

时间:2020-11-04 22:48:48

标签: r ggplot2 bar-chart panelgrid

我有一个ggplot2条形图,已更改了轴刻度。但是,面板网格正在添加我不想要的其他行。如何删除它们?

我的问题:

  1. 我只想要与x轴刻度线匹配的垂直网格线

  2. 位置躲避区保留功能由于存在组和填充而无法正常工作。

我的代码:

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))

数据具有以下结构:

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

我所获得的情节如下(我删除了情节上的图例)

enter image description here

0 个答案:

没有答案