修复R包风的风标

时间:2023-02-05 15:02:55

I would appreciate your help.

我很感激你的帮助。

I am using the function windRose of the openair package for R. I am doing wind roses for wind date from many stations, and I need to compare the results from all roses together. The problem is that the windRose function fixes the maximum radius of the windrose to a little bit more than the maximum % of counts found in any direction. How can I control the maximum scale of the windrose, lets say putting a fixed maximum of 30% for the max plotting radius instead of the default maximum put by the function and which depends on my data? I have explored the code of the function but I have not been able to locate the position in the windRose function code where I could do this change.

我正在使用露天包的函数windRose为R.我正在为许多站点的风日期做风玫瑰,我需要将所有玫瑰的结果进行比较。问题是windRose函数将windrose的最大半径固定为比在任何方向上找到的最大计数百分比稍微多一点。如何控制windrose的最大比例,假设最大绘图半径的固定最大值为30%,而不是函数的默认最大值,这取决于我的数据?我已经探索了函数的代码,但是我无法在windRose函数代码中找到我可以进行此更改的位置。

2 个解决方案

#1


1  

Not exactly an answer to your question, but...

不完全是你的问题的答案,但......

My ggplot2 windrose code where rose is a data.frame with columns of wind_speed and wind_direction in degrees:

我的ggplot2 windrose代码,其中rose是一个data.frame,其中包含wind_speed和wind_direction列,单位为度:

rose <- data.frame(wind_speed=sample(1:25, 1e5, replace=TRUE), 
                   wind_direction=sample(1:360, 1e5, replace=TRUE))

ggplot(rose, 
       aes(x=wind_direction,
           fill=cut(wind_speed, seq(0, 30, 5)))) +
    geom_bar() +
    scale_x_continuous(limits=c(0,360),
                       breaks=c(0, 90, 180, 270)) +
    coord_polar() +
    labs(fill='Wind Speed (m/s)') +
    opts(axis.text.y=theme_blank(),
         axis.ticks=theme_blank(),
         axis.title.y=theme_blank(),
         axis.title.x=theme_blank())

#2


0  

I coded up something here that would help. You can set the axis limits to whatever you need.

我在这里编写了一些有用的东西。您可以将轴限制设置为您需要的任何值。

#1


1  

Not exactly an answer to your question, but...

不完全是你的问题的答案,但......

My ggplot2 windrose code where rose is a data.frame with columns of wind_speed and wind_direction in degrees:

我的ggplot2 windrose代码,其中rose是一个data.frame,其中包含wind_speed和wind_direction列,单位为度:

rose <- data.frame(wind_speed=sample(1:25, 1e5, replace=TRUE), 
                   wind_direction=sample(1:360, 1e5, replace=TRUE))

ggplot(rose, 
       aes(x=wind_direction,
           fill=cut(wind_speed, seq(0, 30, 5)))) +
    geom_bar() +
    scale_x_continuous(limits=c(0,360),
                       breaks=c(0, 90, 180, 270)) +
    coord_polar() +
    labs(fill='Wind Speed (m/s)') +
    opts(axis.text.y=theme_blank(),
         axis.ticks=theme_blank(),
         axis.title.y=theme_blank(),
         axis.title.x=theme_blank())

#2


0  

I coded up something here that would help. You can set the axis limits to whatever you need.

我在这里编写了一些有用的东西。您可以将轴限制设置为您需要的任何值。