【问题标题】:Is there an easy method i can use R's areaplot() with steps instead of interpolated points?有没有一种简单的方法可以使用 R 的 areaplot() 步骤而不是插值点?
【发布时间】:2021-11-20 14:07:59
【问题描述】:

有没有一种简单的方法可以使用 R 的 areaplot() 来代替插值点? 就像 type = "S" 在普通绘图功能中一样。

【问题讨论】:

    标签: r plot area


    【解决方案1】:

    我看不到任何使用areaplot() 的方法,但您可能可以使用rect() 获得您想要的。您应该使用dput() 提供可重现的数据,以获得将您的特定数据特征考虑在内的答案。

    # Some data
    x <- 1:10
    y <- c(39L, 42L, 33L, 38L, 45L, 53L, 28L, 33L, 39L, 42L)
    
    plot(NA, xlim=c(0, tail(x, 1)), ylim=c(0, max(y)), xlab="X", ylab="Y")
    rect(c(0, x), rep(0, 11), c(x, tail(x, 1)), c(y, tail(y, 1)), col="gray", border=NA)
    

    我们需要为每个值绘制一个矩形。因为我们有 10 个值,所以我们绘制 10 个矩形。 rect() 函数使用左下角和右上角来定义每个矩形。

    【讨论】:

      猜你喜欢
      • 2021-04-03
      • 2011-08-23
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 2012-08-19
      • 2020-07-12
      • 1970-01-01
      相关资源
      最近更新 更多