我正在尝试使用facet_grid逐年创建时间序列图,以便将数据绘制在彼此之上。但是,当我绘制它时,由于数据的分解方式,所以有很多空白(即2017年的图形仍然显示了2018年和2019年的时间序列,但没有数据,我想删除此空白) 。如何释放x坐标的比例,使其不显示所有年份?
我的代码
proportion_data %>%
ggplot(aes(x = new_date, group = 1)) +
geom_line(aes(y = prop_elect, color ="elect_prop")) +
geom_line(aes(y = prop_water, color ="water_prop")) +
geom_line(aes(y = prop_natgas, color ="natgas_prop")) +
facet_grid(Year ~., scales = "free" )
我的数据
Utilities by Year
任何建议将不胜感激!
谢谢,克里斯
您是否尝试过使用空格选项?enter image description here另一种选择是使用facet_grid(Year ~., scales = "free" ,space="free_x")
代替facet_wrap
facet_grid