极地图像情节,如何用R做? [英] polar image plot, how to do it with R?

查看:161
本文介绍了极地图像情节,如何用R做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到一种直接的方法来在R中制作漂亮的图像图,但是在极坐标中。我基本上试图在MATLAB中找到'polarplot3d'函数的R等价物。我一直在玩ggplot2包但没有太多运气。我错过了一个包含我正在尝试的功能的包吗?提前感谢任何指示。

I cannot find a straightforward way to make a nice image plot in R, but in polar coordinates. I'm basically attempting to find a R equivalent for the 'polarplot3d' function in MATLAB. I've been playing around with ggplot2 package but without much luck. Am I missing a package that contains functionality for what I'm attempting? thanks in advance for any pointers.

好的,我正在努力更清楚我正在尝试做什么。假设我想定义一个极坐标网格,径向增量为50m,θ为2.5度。这应该看起来像一个飞镖靶。

Ok, I'm trying to be more clear about what I'm trying to do. Lets say I want to define a polar coordinate grid, increments in the radial direction are 50m and 2.5 degrees in theta. This should look like a dartboard.

我的数据(r和下面代码中的角度)对应于径向距离测量和角度。我想要的z值是上面描述的定义网格的增量中r和角度之间的双变量直方图的计数。

My data (r and angle in below code) are correspond to a radial distance measure and an angle. My desired z-value is the counts of a bivariate histogram between r and angle within the increments described above defining the grid.

我的数据如下:

# synthetic data for angle and distance #
angle <- rnorm(500,mean=90,sd=15)
r <- rnorm(500,mean=700,sd=200)

# bivariate histogram #
observations <- table(cut(angle,breaks=c(seq(0,360,by=2.5))),cut(r,breaks=c(seq(0,1400,by=50))))


# the 'z' data are in observations for each bin of bivariate histogram #
# hot to plot a polar coord image? #


推荐答案

这是非常慢在我的系统上渲染,但是

It's very slow to render on my system, but

library(reshape2)
library(ggplot2)
mm <- melt(counts)
ggplot(mm,aes(Var1,Var2,fill=value))+geom_tile()+coord_polar()
ggsave("polar1.png")

似乎有效。

这篇关于极地图像情节,如何用R做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆