R中变量的限制

R中变量的限制,r,function,plot,R,Function,Plot,我想绘制以下函数: D=(x^p+y^p)^(1/p) 但是我想限制x和y,这样:x+y=1,0也许这有帮助: p<-0.1 dp <-function(x,y,p){ (x^p +y^p)^{1/p} } x<-seq(0,1, length=100) Z <- outer(x,x,dp,p) Z[col(Z)+row(Z)>ncol(Z)] <- NA # remove the entries in the upper triangle of the s

我想绘制以下函数:
D=(x^p+y^p)^(1/p)

但是我想限制x和y,这样:
x+y=1
0也许这有帮助:

p<-0.1
dp <-function(x,y,p){  (x^p +y^p)^{1/p} }
x<-seq(0,1, length=100)
Z <- outer(x,x,dp,p)
Z[col(Z)+row(Z)>ncol(Z)] <- NA # remove the entries in the upper triangle of the square matrix
newcols <- colorRampPalette(c("pink","maroon", "red"))
plot1<-wireframe(Z,drape=T,col.regions=newcols(100), screen = list(z =  75, x = -90, y = 80))

p约束x+y=1生成三维线,而不是平面,那么为什么要使用
线框
?这是打字错误吗?我还假设剩余的约束是
0,我认为
Z@Backlin我想画的是函数:(sum_i=1^n x_i^p)^(1/p),其中x_i都是非负的,sum x_i=1(换句话说,x_i属于单位单纯形),我应该取第三个参数,然后在三维图中绘制吗?对不起,这听起来可能很傻,但为什么不做类似这样的事情:
x@RHertel当然不是:)这不是竞争:)
p<-0.1

    dp<-function(x,y,p){
      (x^p +y^p + (1-x-y)^p)^{1/p}
    }

    x<-y<- seq(0,1, length=100)
    Z<-outer(x,y,dp)

    newcols <- colorRampPalette(c("pink","maroon", "red"))

    plot1<-wireframe(Z,drape=T,col.regions=newcols(100)  ,screen = list(z =  75, x = -90, y = -60))
p<-0.1
dp <-function(x,y,p){  (x^p +y^p)^{1/p} }
x<-seq(0,1, length=100)
Z <- outer(x,x,dp,p)
Z[col(Z)+row(Z)>ncol(Z)] <- NA # remove the entries in the upper triangle of the square matrix
newcols <- colorRampPalette(c("pink","maroon", "red"))
plot1<-wireframe(Z,drape=T,col.regions=newcols(100), screen = list(z =  75, x = -90, y = 80))