代码之家  ›  专栏  ›  技术社区  ›  ben

如何将参数传递给plot.surface()[r fields包]中的contour()。

  •  0
  • ben  · 技术社区  · 6 年前

    当使用r fields包的plot.surface()时,我需要将contour()函数的“method”参数从默认设置“flattest”更改为“simple”。

    contour()函数在plot.surface()中。

    plot.surface()文档说明,可以将其他参数传递给plot.surface()中出现的其他两个函数,但没有提到如何将参数传递给contour()。

    我需要这样做,因为在我的绘图等高线出来的直线,导致没有数字的线。我想如果我能把轮廓法从“平面”变为“简单”或“边缘”,我就能得到轮廓线上的数字。

    这是等高线图像:

    enter image description here

    用于生成图像的代码:

    inMat <- mat_Qe
    surface <- list(x = xtick_labs,
                    y = ytick_labs,
                    z = inMat)
    plot.surface(surface, type = "C",
                 xlab = "Mean factory efficiency (kL Ethanol / MT Root)",
                 ylab = "Mean farm cost (lcu / MT Root)", labcex = 1, col = mapPalette(45))
    title(main = "Equilibrium Quantity Map (MT / day)", cex.main = 1)
    

    抱歉,它不是可复制的,但我认为在这种情况下,可复制性并不是真的必要的。我只需要有人告诉我如何将方法参数传递给plot.surface()中的contour()。

    1 回复  |  直到 6 年前
        1
  •  0
  •   Anders Ellern Bilgrau    6 年前

    修改中的示例 ?plot.surface ,以下将通过 method contour . 如果你跑 plot.surface 你会看到椭圆( ... )给定轮廓如果 type = "c" 尽管文档中似乎没有说明这一点。注意这是小写的 c 不是 C . 用资本 "C" 参数未传递给 轮廓 但是 image.plot

    library("fields")
    
    # Toy data
    x <- seq( -2,2,,80)
    y <- seq( -2,2,,80)
    z <- outer( x,y, "+")
    obj <- list(x=x, y=y, z=z)
    
    # Pass method to contour when type = "c"
    plot.surface(obj, col="red", type="c", method = "simple")
    

    enter image description here

    plot.surface(obj, type="c", col="red", method = "edge")
    

    enter image description here