给出一个x轴是离散的图,由有序因子给出,如下图:
级别:
D E F G H I J
1 1 1 2 2 3 4
有办法吗?
scale_x_discrete(breaks=c("D","G", "I", "J"), lables=c(1,2,3,4))
没有手动复制中断?
答案 0 :(得分:0)
这就是你要追求的吗?
keeps<-c(1,4,6,7) # Indices for levels you want to show
ggplot(data=diamonds)+
geom_bar(aes(x=color,y=carat),stat="identity")+
scale_x_discrete(
breaks=levels(d$color)[keeps],
labels=table(d$color)[keeps])