【问题标题】:How to get nice arrowheads in logarithmic r plot using IDPmisc?如何使用 IDPmisc 在对数 r 图中获得漂亮的箭头?
【发布时间】:2015-12-31 17:02:28
【问题描述】:

我想用 IDPmisc 或其他库在对数 r 图中绘制实心箭头。箭头以对数方式拉伸。

一个简单的例子(文档例子稍作修改)是:

library(IDPmisc)

plot(c(4,10), c(0,10), type="n",log = "x")
Arrows(5, 5, 5,10, size=3,
   sh.lwd=5, sh.lty=2,
   h.lwd=5)
Arrows(5, 5, 7.5, 9, size=3, open=TRUE,
   sh.adj=0.7, sh.lwd=5, sh.lty=2,
   h.col.bo="red",h.lwd=5)
Arrows(5, 5, 9, 7.5, size=3, open=FALSE,
   sh.adj=1, sh.lwd=5, sh.col="blue",
   h.col.bo="red",h.lwd=2)
Arrows(5, 5, 10, 5, size=2.5, width=1.5, open=FALSE,
   sh.adj=1, sh.lwd=7, sh.col="blue")

我尝试定义一个新的 Arrows.log(就像它已完成 here)并更改角度:

deg.arr <- c(atan2(y.arr, exp(x.arr)), NA)
theta <- atan2((y2 - y1) * uin[2], exp((x2 - x1)) * uin[1])

但它不起作用(我没有完全理解 Arrows 函数)并且已经遇到了 Arrows 中使用的 xyinch() 函数的问题。

如果您建议一种简单的方法来在对数图中绘制带有实心箭头的漂亮箭头,而无需重新定义 IDPmisc 箭头,我会很高兴。

【问题讨论】:

    标签: r plot logarithm


    【解决方案1】:

    您是否尝试过类似以下的方法

    plot(log10(c(4,10)), c(0,10), type="n")
    Arrows(log10(5), 5, log10(5),10, size=3,
       sh.lwd=5, sh.lty=2,
       h.lwd=5)
    Arrows(log10(5), 5, log10(7.5), 9, size=3, open=TRUE,
          sh.adj=0.7, sh.lwd=5, sh.lty=2,
          h.col.bo="red",h.lwd=5)
    Arrows(log10(5), 5, log10(9), 7.5, size=3, open=FALSE,
          sh.adj=1, sh.lwd=5, sh.col="blue",
          h.col.bo="red",h.lwd=2)
    Arrows(log10(5), 5, log10(10), 5, size=2.5, width=1.5, open=FALSE,
          sh.adj=1, sh.lwd=7, sh.col="blue")
    

    这似乎奏效了。不过,这可能不是最好的方法。

    输出

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-10
      • 1970-01-01
      相关资源
      最近更新 更多