如何在R中使用包'circular'在玫瑰图中移动垃圾箱 [英] How to shift bins in a rose diagram using package 'circular' in R

查看:164
本文介绍了如何在R中使用包'circular'在玫瑰图中移动垃圾箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用R中的圆形"包和rose.diag函数为N,NE,E等基本方面创建了用于位置数据的度方面的玫瑰图,共有8个面元.但是,垃圾箱不会跨越各个方面.换句话说,第一个bin的取值范围是0-45,第二个bin的取值范围是45至90,依此类推,它们以奇怪的方式合并了方面数据.有什么方法可以移动垃圾箱,让0、45、90等位于垃圾箱的中心,而不是边缘吗?

I created a rose diagram of aspects in degrees for location data using the 'circular' package in R and the rose.diag function, with basic aspects of N, NE, E, etc., for a total of 8 bins. However, the bins do not straddle the aspects. In other words, the first bin goes from 0-45, the 2nd from 45 to 90, and so on, which is pooling the aspect data in strange ways. Is there any way to shift the bins so 0, 45, 90, etc are the center of the bins, instead of the edges?

rose.diag(Degrees$Degrees, bins=8,zero=pi/2, units = 'degrees', rotation='clock')

推荐答案

我认为Ben是对的,因为使用rose.diag无法轻松完成,所以这里是使用ggplot2的解决方案:

I think Ben is right that it cannot be done easily with rose.diag, so here is a solution using ggplot2:

library(ggplot2)
Degrees <- runif(100, 0, 360)
rose <- ggplot(mapping = aes(x = Degrees)) +
  stat_bin(breaks = (0:8 - 0.5)/8 * 360) +
  scale_x_continuous(
    breaks = 0:7/8*360, 
    labels = c("N", "NE", "E", "SE", "S", "SW", "W", "NW")
    ) +
  coord_polar(start=-pi/8)
rose

这可能不是理想的,因为rose.diag中的所有功能并非在ggplot2中都具有简单的等效项.

This may not be ideal because not all of the features in rose.diag have easy equivalents in ggplot2.

这篇关于如何在R中使用包'circular'在玫瑰图中移动垃圾箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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