How can I suppress the vertical gridlines in a ggplot2 plot while retaining the x-axis labels?

前端 未结 5 1020
轮回少年
轮回少年 2021-02-19 23:54

This is a follow-on from this question, in which I was trying to suppress the vertical gridlines.

The solution, as provided by learnr, was to add scale_x_continuous(brea

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-20 00:19

    You can do this editing the grob directly, try:

    grid.remove(gPath("panel.grid.minor.x.polyline"),grep=T)
    grid.remove(gPath("panel.grid.major.x.polyline"),grep=T) 
    

    It will strip off your vertical lines. I'm just having problems to use it inside a function, because I guess that it only works when the ggplot is printed.

    But, if that's not your case and you'll just need the graphic, than it will work.

提交回复
热议问题