R / Matlab:在心形中创建散点图

时间:2014-12-19 17:05:49

标签: r matlab

我找到了一个Matlab脚本来生成心形的散点图,但是,我想在R中绘制这个图。

http://scriptdemo.blogspot.co.at/2013/02/show-normal-random-heart.html

有人可以帮我解释或转换代码,以便我可以在R?

中使用它

提前致谢, 菲利普

1 个答案:

答案 0 :(得分:6)

这似乎是一个相当基本的翻译

r <- 0.618
n <- 10000
re <- sqrt(1-r*r);
x <- rnorm(n);
y <- x*r+rnorm(n)*re
y[x<0] <- -y[x<0];

par(mar=rep(0,4))
plot(x,y, col=rgb(1,0,1), axes=F, asp=1)

enter image description here

相关问题