为什么geom_freqpoly从零开始添加线,即使其中没有数据?

为什么geom_freqpoly从零开始添加线,即使其中没有数据?,r,ggplot2,R,Ggplot2,我正在使用ggplot2生成频率图。我的数据的X轴是年龄,从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="ribb

我正在使用ggplot2生成频率图。我的数据的X轴是年龄,从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))