简体   繁体   English

根据两条曲线形成多边形

[英]Forming polygon based on two curves

I have fit 3 separate logarithmic curves to a series of human growth data via maximum likelihood estimation. 通过最大似然估计,我将3条独立的对数曲线拟合到一系列人类生长数据。 Each of these curves is plotted as follows: 这些曲线的每一个都绘制如下:

cedar.plot.MEAN<-curve(cedar.estim.MEAN, from = 0, to = 18)
cedar.plot.MAX<-curve(cedar.estim.MAX, from = 0, to = 18, add = TRUE)
cedar.plot.MIN<-curve(cedar.estim.MIN, from = 0, to = 18, add = TRUE)

Femur length ~ MINAGE, MEANAGE, MAXAGE 股骨长度〜MINAGE,MEANAGE,MAXAGE

Essentially, I would like to plot the middle curve - the Mean - bounded by a polygon of the upper and lower curve. 本质上,我想绘制中间曲线-均值-由上下曲线的多边形界定。 I have tried the polygon function: 我试过了多边形函数:

polygon(c(cedar.plot.MIN),c(cedar.plot.MAX),col = "grey75", border = FALSE)

But, the syntax is wrong. 但是,语法错误。 What is the best way to plot a polygon around the mean curve bounded by the upper and lower. 在围绕上下限的平均曲线周围绘制多边形的最佳方法是什么。

polygon needs the x and y coordinates of the points. polygon需要点的x和y坐标。 Since you do not provide your functions, I cannot test, but you need something like 由于您没有提供功能,因此我无法测试,但是您需要

polygon(c(cedar.plot.MIN$x, rev(cedar.plot.MAX$x)), c(cedar.plot.MIN$y, rev(cedar.plot.MAX$y)), col="#88888833")

Here is a tested example. 这是一个经过测试的示例。

C = curve(sin, from=0, to=12, ylim=c(-1,3))
C2 = curve(Sp2, from=0, to=12, add=TRUE)
polygon(c(C$x, rev(C2$x)), c(C$y, rev(C2$y)), col="#88888833")

曲线之间的面积

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM