【发布时间】:2015-09-29 11:16:32
【问题描述】:
给定一个 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))
无需手动复制中断?
【问题讨论】:
给定一个 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))
无需手动复制中断?
【问题讨论】:
这就是你所追求的吗?
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])
【讨论】: