2017-03-29 117 views
2

错误?可能相关to this..scale_y_discrete忽略中断/标签

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

+0

'是否下降= FALSE'在'scale_y_discrete'你想要什么?如果没有,你需要澄清你想要输出的样子。 – Miff

回答

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

resulting plot

+0

啊,谢谢罗兰。如果这是在'scale_y_discrete'文档中会有帮助。 – geotheory

+0

请参阅椭圆的文档。 – Roland

+1

这不是假设对ggplot有相当深入的了解吗? – geotheory