0
我想讓我的數據點等於0出現在x軸上,並避免由軸切割數據點。 我也想保持原來的狀態(對於兩個軸同樣爲0)。如何使數據點等於0出現在使用ggplot的座標軸上?
我用這個得到的原點爲0,並設置我的軸線的界限:
scale_y_continuous(limits = c(0, 40), expand = c(0, 0))+
scale_x_continuous(limits = c(0, 30), expand = c(0, 0))
如果我改變Y的用於
scale_y_continuous(limits = c(-1, 40))
限制它也改變了原點...
這是我的代碼,以防萬一你需要它:
require(ggplot2)
myplot<-ggplot(data=NULL,aes(x = Length, y = Complete)) +
geom_point(data = C,shape=1, size=3)+
geom_point(data = T, size=3)+
scale_y_continuous(limits = c(0, 40), expand = c(0, 0))+
scale_x_continuous(limits = c(0, 30), expand = c(0, 0))+
xlab("Inflorescence Length (cm)")+
ylab("Successful Weevils")+
theme_bw() +
theme(panel.border = element_blank())+
theme(panel.grid.major = element_blank())+
theme(panel.grid.minor = element_blank())+
theme(axis.text=element_text(size=12))+
theme(axis.title=element_text(size=14,face="bold"))+
theme(axis.line.x=element_line())+
theme(axis.line.y=element_line())+
theme(plot.margin = unit(c(1,1,1,1), "cm"))+
stat_smooth(data = C, method = lm, se=FALSE, color="grey")+
stat_smooth(data = T, method = lm, se=FALSE, color="black")
myplot
謝謝!