Customizing x-axis of graph

后端 未结 2 798
伪装坚强ぢ
伪装坚强ぢ 2021-01-23 13:53

I am using scale_x_discrete() to customize ticks and labels of x-axis.

However, as figure shows, the lines cut the right-side y-axis, which doesn\'t look g

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 14:42

    Why are you using a discrete scale for something at appears to be continuous.

    If you replace scale_x_discrete with scale_x_continuous then this should work as you wish.

    b <- a + scale_x_continuous(breaks = 2^(1:7))
    b
    

    enter image description here You might be interested in a transformation to base 2, given the way your data for b appear only to be integer powers of 2.

    a + scale_x_continuous(breaks = 2^(1:7), trans = 'log2')
    

    enter image description here

提交回复
热议问题