scale_y_discrete忽略中断/标签

时间:2017-03-29 08:33:39

标签: r ggplot2

错误?可能相关to this..

dat = data.frame(x = 1:4, y = ordered(c(4,'>5',1,1), levels = c(1:5, '>5')), grp = 1)

ggplot(dat, aes(x, y, group=grp)) + geom_step() + 
  scale_y_discrete(breaks = levels(dat$y), labels = levels(dat$y))

enter image description here

1 个答案:

答案 0 :(得分:5)

ggplot(dat, aes(x, y, group=grp)) + geom_step() + 
  scale_y_discrete(breaks = levels(dat$y), labels = levels(dat$y), drop = FALSE)

resulting plot