在具有缩放轴和偏移轴的绘图中添加一个点?

Add a single point in plot with scaled and offset axes?

我有下一个代表情节的代码。

x1<-0:200
a1<-dnorm(x1,88.24,15)
b1<-dnorm(x1,92,16)
c1<-dnorm(x1,104,15)

x2<-400:1200
a2<-dnorm(x2,747.88,65.9792)
c2<-dnorm(x2,835,117)

scale<-range(pretty(range(a1,a2,b1,c1,c2)))

remap<-function(x, to, from=range(x)) {
    (x-from[1]) / (from[2]-from[1]) * (to[2]-to[1]) + to[1] 
}

plot(NA, NA, xaxt="n", yaxt="n", type="n", xlim=scale, ylim=scale, xlab="X", ylab="Y")

rect(remap(83, scale, range(x1)), scale[1],
     remap(93, scale, range(x1)), scale[2], col="#ff606025", lty=0)
rect(remap(82, scale, range(x1)), scale[1],
     remap(102, scale, range(x1)), scale[2], col="#3ca90025", lty=0)
rect(remap(67, scale, range(x1)), scale[1],
     remap(141, scale, range(x1)), scale[2], col="#3847ea25", lty=0)
rect(scale[1], remap(729, scale, range(x2)),
     scale[2], remap(767, scale, range(x2)), col="#ff606025", lty=0)
rect(scale[1], remap(544, scale, range(x2)),
     scale[2], remap(1126, scale, range(x2)), col="#3847ea25", lty=0)

lines(remap(x1,scale), a1, col="#ff6060", lwd=2)
lines(remap(x1,scale), b1, col="#3ca900", lwd=2)
lines(remap(x1,scale), c1, col="#3847ea", lwd=2)

lines(scale[2]-a2, remap(x2,scale), col="#ff6060", lwd=2)
lines(scale[2]-c2, remap(x2,scale), col="#3847ea", lwd=2)

axis(2); axis(3)
axis(1, at=remap(pretty(x1), scale), pretty(x1))
axis(4, at=remap(pretty(x2), scale), pretty(x2))

您可以看到以下内容的表示:

如何在此图中添加一个点?例如当点为X=100 Y=600.

提前致谢

创建一个带有单个点的单独数据集,或者对现有数据集的查询 returns 数据集中的单个点,并将其传递给 points 函数。

在这里查看积分函数:http://www.inside-r.org/r-doc/graphics/points

试试这个:

points( x=100*diff(scale)/diff(range(x1)), #could also use remap(100, scale, range(x1))
        y=remap(600, scale, range(x2) ), 
    col="red", cex=3)