避免在R的图中修剪曲线

问题描述

如何避免切掉我的曲线(绿线)?

x <- Phoenix_August_clean$Sum.Precipitation.Total.August
curve(dnorm(x,mean = fit.gaussian2$estimate[1],sd = fit.gaussian2$estimate[2]),lwd=3,col="red",add=TRUE)
curve(dgamma(x,fit.gamma.mme$estimate[1],fit.gamma.mle$estimate[2]),col="orange",add=TRUE) #Maximum likelihood
curve(dgamma(x,fit.gamma.mme$estimate[2]),col="green",add=TRUE) #Method of moments
legend("topright",legend=c("normal","Gamma - ML","Gamma - MM"),col=c("red","orange","green"),lty=1,lwd=1)

结果:

enter image description here

解决方法

根据当时已知的数据在第一个图上设置限制(显然是为您调用Column),因此您需要在上自行设置hist 调用,基于要绘制的曲线。

问题图:

ylim=

sample plot,curve off the page

固定图,手动添加hist(mtcars$disp,freq=FALSE) curve(dgamma(x-100,50)/10,lwd=3,col="red",to=500,add=TRUE)

ylim=...

sample plot,fixed