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:
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.
精彩评论