我正在使用ggplot2来生成频率图。我的数据的X轴是AGE
,它从18开始,到44结束。但是,当我生成AGE
的频率图时,图形看起来像这样:
我希望这些行从18开始到44结束。这怎么可能?
代码是:
ggplot(matched.frame, aes(x=AGE, fill=as.factor(DRUG_KEY), color=as.factor(DRUG_KEY))) +
stat_bin(aes(ymax=..count..,), alpha=.5, ymin=0, geom="ribbon", binwidth =5, position="identity", pad=T) +
geom_freqpoly(binwidth=5, size=2) +
scale_fill_discrete(labels = c("26"="foo", "27"="bar"), name = "Labels") +
scale_color_discrete(labels = c("26"="foo", "27"="bar"), name = "Labels") +
scale_x_continuous(breaks=seq(18, 44, 2)) +
xlab("AGE") + ylab("Number of Patients") +
theme(axis.text.x = element_text(face="bold", size=12)) +
theme(axis.text.y = element_text(face="bold", size=12)) +
theme(axis.title.x = element_text(face="bold", size=14)) +
theme(axis.title.y = element_text(face="bold", size=14))