开发者

Is it possible to split X-Axis labels into two levels?

My X-axis labels are strings and rotating them is开发者_JS百科 making my plot look ugly. In ggplot, is there a way to split up the X-axis labels such that half of them appear on the top and half on the bottom (alternating style). So instead of:

Label1 Label2 Label3 Label4

I want:

Label1   Label3
    Label2    Label4


You can always prepend the x axis values with alternating newline characters:

dat <- data.frame(x = c('Label1','\nLabel2','Label3','\nLabel4'),y = 1:4)
ggplot(data = dat, aes(x = x, y = y)) + 
  geom_point()

which produces this:

Is it possible to split X-Axis labels into two levels?

As a side note, I thought that perhaps you could pass a vector of values to vjust in opts, but that didn't seem to work. It might in the development version though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜