简体   繁体   English

R中的3D极坐标图

[英]3D polar plot in R

I have plotted polar coordinates for my data by using ggplot2 . 我已经使用ggplot2为数据绘制了极坐标。

my dataset is in this format: 我的数据集采用以下格式:

 Time    Lat    Long   Act
 18:00  21.05   70.00  feed
 18:45  21.00   75.00  walk
 19:00  21.09   77.00  walk
 19:05  24.98   77.09  rest

Code : 代码:

library(ggplot2)
plot.new()

ggplot(aes(x = Lat, y = Long, colour = Act), data = file) + 
geom_point() 
ggplot(aes(x= Lat, y = Long , colour = Act), data = file) + 
geom_point() + 
coord_polar(theta = "y")

This is the polar coordinate plot which I get: here 这是我得到的极坐标图: 在这里

This plot is having latitude and longitude. 该图具有经度和纬度。 Now I would like to add one more dimension "time". 现在,我想再增加一个维度“时间”。 How can I do this ?. 我怎样才能做到这一点 ?。 How can I make this 2D polar plot in 3D polar plot ? 如何在3D极坐标图中制作此2D极坐标图?

You could try to scale the size of the points with the value of the variable "time". 您可以尝试使用变量“时间”的值缩放点的大小。 Unfortunately your example is not reproducible, but something along these lines could work: 不幸的是,您的示例无法重现,但可以遵循以下方法进行操作:

ggplot(aes(x= Latitude, y = Longitude , colour = ACTIVITY, size=time), data = Data) + geom_point(shape=21) + coord_polar(theta = "y") + scale_size_area(max_size=10)

Below you can see a reproducible example, which is based on data that is used in "The R Graphics Cookbook" by Winston Chang (O'Reilly 2013). 在下面,您可以看到一个可复制的示例,该示例基于Winston Chang(O'Reilly 2013)在“ The R Graphics Cookbook”中使用的数据。

In this case, the dot size represents the temperature, the color refers to a wind speed category, the direction of the wind is plotted in polar coordinates and the radius is the average value of the wind. 在这种情况下,点的大小表示温度,颜色表示风速类别,风的方向绘制在极坐标中,半径是风的平均值。

library(gcookbook)
library(ggplot2)
p <- ggplot(wind, aes(x=WindDir, y=WindAvg, size=Temp, fill=SpeedCat)) +
     coord_polar() + geom_point(shape=21)+scale_size_area(max_size=10) +
     scale_x_continuous(limits=c(0,360),breaks=seq(0,360,by=45))

This is the output: 这是输出: 在此处输入图片说明

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM