0

我最近发布了一篇关于将 xy 图控制为两条正态曲线的帖子,并且后来意识到我把事情弄得太复杂了。从那以后,我设法将其绘制为椭圆,但这略微高估了错误;理想情况下可以绘制为菱形。

我必须迄今为止的代码是:

plot(c(-5,10), c(-5,5),  xlab = expression(Age), ylab = expression(value), type="n")
draw.ellipse(Age, value, a=Age_error, b=value_error, col="grey70")

哪些情节: 椭圆形

有没有办法用菱形替换椭圆,菱形的高度由 2x value_error 控制,宽度由 2x age_error 控制?

我的数据框在下面

  structure(list(Age = c(1L, 2L, 4L), value = c(3, -2, 0.01), Age_error = c(2, 
  1.4, 3), value_error = c(0.5, 1, 2.1)), .Names = c("Age", "value", 
  "Age_error", "value_error"), class = "data.frame", row.names = c(NA, 
  -3L))

非常感谢

4

1 回答 1

1

You can use the my.symbols and ms.polygon functions in the TeachingDemos package to draw the rhombuses:

library(TeachingDemos)
plot(c(-5,10), c(-5,5),  xlab = expression(Age), ylab = expression(value), 
    type="n")
my.symbols( Age, value, ms.polygon, n=4, xsize=2*Age_error, 
    ysize=2*value_error, linesfun=polygon, col='grey' ) 

Leave out linesfun and col if you don't want the rhombuses filled.

于 2013-08-22T16:46:20.520 回答