风玫瑰图与ggplot [英] Wind rose chart with ggplot

查看:173
本文介绍了风玫瑰图与ggplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用来自Andy Clifton的梦幻风玫瑰R代码,它的 https://stackoverflow.com/a/17266781/ 709777 ,用于绘制从气象模型中提取的数据。从模型中,我可以得到u和v风分量,单位为m / s。然后我计算风速和风向并尝试风玫瑰码。但我不确定它是否按预期工作,或者我不明白该功能在做什么。



我尝试使用Andy的函数和以下代码来绘制4风玫瑰:

  flist< -c(03050,12010,46070,46050)

for(i in 1:4){

windfile = paste(viento - ,flist [i],。csv,sep =)
viento = read.table(windfile,sep =;,header = F)
colnames(viento)< - c(u,v)
fecha = read.table (ffhh.txt,header = F,sep =;)
colnames(fecha)< -c(date,hr)

wind< -cbind .data.frame(fecha,viento)

wind $ speed = sqrt(wind $ u * wind $ u + wind $ v * wind $ v)
wind $ dir = windDir(wind $ u,wind $ v)

graf = paste(RAMS-wind-rose - ,flist [i],。png,sep =)
png(graf ,res = 240,width = 3000,height = 2400)
plot.windrose(data = wind,spd =speed,dir =dir)
dev.off()


$ / code>

图形输出是



因此最大风速在18-20米/秒范围内。这样对吗?但是,如果我寻找最大风速,我会得到不同的价值

pre $ max $ wind $ speed
[1] 10.24317

也许我误解了 wind.rose 函数运行,或者在调用函数时可能有问题。任何建议,将不胜感激,我现在​​卡在这里。

风数​​据:

  dput(wind)

structure(list(date = structure(c(1L,1L,1L,1L,1L,1L,1L,
1L,1L,1L ,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L, ,2L,2L,2L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L, b $ b 3L,3L,3L,3L,3L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,
4L,4L,4L,4L,4L,4L ,4L,4L,4L,4L,4L,4L,4L,5L,1L,1L,
1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L ,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L, ,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L ,3L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L,4L, ,
4L,4L,5L),.Label = c(2015/05/05,05/06/2015,05/07/2015,
05/08 / 2015,05/09/20 (15L),class =factor),hr = c(12L,13L,
14L,15L,16L,17L,18L,19L,20L,21L,22L,23L,0L,1L,2L, b $ b 3L 4L 5L 6L 7L 8L 9L 10L 11L 12L 13L 14L 15L 16L $ b 17L 18L 19L 20L 21L 22L 23L 0L ,1L,2L,3L,4L,5L,6L,
7L,8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L,19L,
20L,21L ,22L,23L,0L,1L,2L,3L,4L,5L,6L,7L,8L,9L,10L,
11L,12L,13L,14L,15L,16L,17L,18L,19L,20L ,21L,22L,23L,
0L,12L,13L,14L,15L,16L,17L,18L,19L,20L,21L,22L,23L,
0L,1L,2L,3L,4L ,5L,6L,7L,8L,9L,10L,11L,12L,13L,14L,
15L,16L,17L,18L,19L,20L,21L,22L,23L,0L,1L,2L,3L ,
4L,5L,6L,7L,8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,
18L,19L,20L,21L,22L,23L, ,1L,2L,3L,4L,5L,6L,7L,
8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L,19L,20L,
21L ,22L,23L,0L),u = c(1.967012,1.520496,2.144549,2.236543,
2.352827,2.295602,2.320738,2.338692,2.412154,2 .612796,3.032838,
3.62067,4.216179,4.614041,4.746128,4.677606,4.449001,4.098231,
3.565422,2.594458,-1.378813,-3.703259,-3.874501,-3.617813,
-3.360489, -3.179794,-3.073682,-3.053857,-3.100727,-3.193508,
-3.409015,-3.93074,-4.45107,-4.840204,-5.139567,-5.436072,
-5.776207,-6.371346,-7.121193, -7.59635,-7.894677,-7.906566,
-7.483042,-6.81692,-5.891807,-4.977591,-4.057455,-3.212969,
-2.421152,-1.546586,-0.455518,0.639647,2.054146,3.487688,
5.05859,7.112991,8.424683,9.222707,9.661589,9.87525,9.978607,
9.800485,9.46149,9.037914,8.542727,7.966156,7.308363,6.567787,
5.676618,4.929429,4.24888,3.619122,3.071927, 2.662167,2.388519,
2.199777,2.059402,1.941171,1.826771,1.742619,1.653258,1.61614,
1.66758,1.813451,1.98155,1.967012,1.520496,2.1445498,2.336543,
2.352827,2.295602,2.320738, 2.38692,2.412154,2.612796,3.032838,
3.62067,4.216179,4.614041,4 .746128,4.67606,4.49001,4.098231,
3.565422,2.594458,-1.378813,-3.703259,-3.874501,-3.617813,
-3.360489,-3.179794,-3.073682,-3.053857,-3.100727,-3.193508 ,
-3.409015,-3.93074,-4.45107,-4.840204,-5.139567,-5.436072,
-5.776207,-6.371346,-7.121193,-7.59635,-7.894677,-7.906566,
- 7.483042,-6.81692,-5.891807,-4.977591,-4.057455,-3.212969,
-2.421152,-1.546586,-0.455518,0.639647,2.054146,3.487688,
5.05859,7.112991,8.424683,9.222707,9.661589, 9.87525,9.978607,
9.800485,9.46149,9.037914,8.542727,7.966156,7.308363,6.567787,
5.676618,4.929429,4.22488,3.619122,3.071927,2.6662167,2.388519,
2.199777,2.059402,1.941171, v = c(-2.766112,-0.478182,-0.192239,
-0.124549,-0.263261,-0.265564,-0.47101,-1.788897) ,-1.908823,
-1.305634,-0.531897,0.247035,0.92907,1.3397227,1.65391,1.778991,
1.82894,1.8894 1852,1.752565,1.585399,1.592519,2.354492,2.532527,2 $ b 2.313413,2.016459,1.792902,1.670022,1.599441,1.599147,1.650283,
1.745915,2.0444,2.540668,3.210907,3.841764,4.3323583,4.700086,
4.940802,5.083652,5.159999,5.12434,5.00041,4.6663396,4.229373,
3.665845,3.217579,2.847133,2.461892,2.082835,1.615325,0.950391,
0.172732,-0.249755,-0.452249,-0.756625, - 1.250214,-1.653063,
-1.854439,-1.986611,-2.139991,-2.312994,-2.468648,-2.499339,
-2.647794,-2.835616,-3.010868,-3.093763,-3.025498,-2.79024,
-2.552279,-2.296148,-1.938917,-1.563025,-1.275801,-1.101657,
-1.015782,-1.001581,-0.981939,-0.963097,-0.956454,-0.849296,
-0.603197, -0.285416,0.060993,0.38673,-2.766112,-0.478182,
-0.192239,-0.124549,-0.263261,-0.265564,-0.47101,-1.788897,
-1.908823,-1.305634,-0.531897,0.247035, 0.92907,1.3397227,
1.65391,1.787991,1.82894,1.81852,1.752565,1.585399,1.592519,
2.354492,2.532527,2.313413,2.016459,1.792902,1.670022,1.599441,
1.599147,1.650283,1.745915,2.0444,2.540668,3.210907,3.841764,
4.323583,4.700086,4.940802,5.083652,5.159999,5.12434,5.00041,
4.663396,4.229373,3.665845,3.217579,2.847133,2.461892,2.082835,
1.615325,0.950391,0.1172732,-0.249755,-0.452249,-0.756625,
-1.250214,-1.653063,-1.854439, -1.986611,-2.139991,-2.312994,
-2.468648,-2.499339,-2.647794,-2.835616,-3.010868,-3.093763,
-3.025498,-2.79024,-2.552279,-2.296148,-1.938917, -1.563025,
-1.275801,-1.101657,-1.015782,-1.001581,-0.981939,-0.963097,
-0.956454,-0.849296,-0.603197,-0.285416,0.060993,0.38673
), speed = c(3.39418794480919,1.59391534001653 2.15409319694506
2.36870672272888 2.3675095028426 2.31091167734728 2.36805305783971
2.98287437935442 3.07605139180817 2.92085314241781 3.07912662176355
3.62908770080374 4.31732977949809 4.8209560918 1519年,5.02604708299514,
5.01702719021105,4.81026313434109,4.48358253183333,3.9740645765147,
3.04051020438429,2.10647621736634,4.38836641577991,4.62876344229536,
4.29423457807535,3.91905514350105,3.65042291577839,3.49807011330648,
3.44735465087797,3.48880768402874,3.59470823936422, 3.83009170353009,
4.43060811938948,5.12513590367358,5.80839896393705,6.41672031330531,
6.94580799814341,7.4468366246511,8.06260344150201,8.7495661264061,
9.1831434162002,9.41194907391285,9.3550994692978,8.81720929923862,
8.02234343939033,6.93915047316846,5.92699137712567,4.95672345372566,
4.04772553598005,3.19377185226638,2.2363369851212,1.0539163634772,
0.662559150893715,2.06927362843608,3.51688736574617,5.11486208794773,
7.22202714006788,8.58533056628911,9.4072986777592,9.86371761914553,
10.1044606012682,10.243170354167,10.1066180883186,9.78603537991872,
9.41778649884526,9.00105008851662,8.5161 5920058802,7.93621693503511,
7.23114542969321,6.32530087628438,5.55098174739226,4.82955454238836,
4.10578167755825,3.4467060570861,2.95208423448417,2.63033670069252,
2.42297996715883,2.29004390725702,2.17539629745065,2.06510244730134,
1.98784436847481,1.85864620360627,1.72503771564827, 1.69182899533493,
1.8144764190945,2.02051078861881,3.39418794480919,1.59391534001653,
2.15409319694506,2.36870672272888,2.3675095028426,2.31091167734728,
2.36805305783971,2.98287437935442,3.07605139180817,2.92085314241781,
3.07912662176355,3.62908770080374,4.31732977949809,4.82095609181519,
5.02604708299514,5.01702719021105,4.81026313434109,4.48358253183333,
3.9740645765147,3.04051020438429,2.10647621736634,4.38836641577991,
4.62876344229536,4.29423457807535,3.91905514350105,3.65042291577839,
3.49807011330648,3.44735465087797,3.48880768402874,3.59470823936422,
3.83009170353009,4.430608119389 48,5.12513590367358,5.80839896393705,
6.41672031330531,6.94580799814341,7.4468366246511,8.06260344150201,
8.7495661264061,9.1831434162002,9.41194907391285,9.3550994692978,
8.81720929923862,8.02234343939033,6.93915047316846,5.92699137712567,
4.95672345372566,4.04772553598005, 3.19377185226638,2.2363369851212,
1.0539163634772,0.662559150893715,2.06927362843608,3.51688736574617,
5.11486208794773,7.22202714006788,8.58533056628911,9.4072986777592,
9.86371761914553,10.1044606012682,10.243170354167,10.1066180883186,
9.78603537991872,9.41778649884526,9.00105008851662, 8.51615920058802,
7.93621693503511,7.23114542969321,6.32530087628438,5.55098174739226,
4.82955454238836,4.10578167755825,3.4467060570861,2.95208423448417,
2.63033670069252,2.42297996715883,2.29004390725702,2.17539629745065,
2.06510244730134,1.98784436847481,1.85864620360627,1.72503771564827,
1.69182899533493,1.814476 4190945,2.02051078861881),DIR = C(324.582958174723,
287.457881896944,275.120092612918,273.014060101878,276.384347431893,
276.598861790546,281.472746249524,306.85002863764,308.355818041581,
296.551646657085,279.947330562416,266.096810627237,257.573002083306,
253.152602628538,250.787798573866,249.121675592407,247.652924389215,
246.071562949111,243.788876501029,238.572092345486,139.113779336087,
122.447759192368,123.170217537641,122.596909573894,120.965832554958,
119.416137865804,118.516536815783,117.643054658187,117.281647992718,
117.328194221248 ,117.119095146817,117.479195348135,119.717697802906,
123.559602263005,126.777668542303,128.497005101731,129.135167930612,
127.79258494314,125.522147782669,124.187227469739,122.987117968321,
122.310801292645,121.930963285117,121.816410282942,121.889612313365,
122.879148352072,125.057498240586 ,127.460629717786,130.704294359997,
136.24 539694722,154.39181584582,254.888144850326,276.932326801277,
277.388325995937,278.506798594382,279.968762057109,281.101348461141,
281.369043841337,281.619184732637,282.227081687741,283.050420058574,
284.138138210954,284.797200895241,286.328746582848,288.362726758368,
290.704458912889, 292.943824332615,294.733498374596,296.175598342547,
297.373477244996,298.387794419952,298.179840415319,296.9674148962,
295.605326053392,294.760576510127,294.785882352792,295.935765474742,
296.832512250004,297.798770744004,298.760625478154,297.190041875953,
290.467240727854,279.712395757604, 268.073659209118,258.965379766511,
324.582958174723,287.457881896944,275.120092612918,273.014060101878,
276.384347431893,276.598861790546,281.472746249524,306.85002863764,
308.355818041581,296.551646657085,279.947330562416,266.096810627237,
257.573002083306,253.152602628538,250.787798573866, 249.121675592407,
247.652924389215,246.071562949111,243.788876501029,238.572092345486,
139.113779336087,122.447759192368,123.170217537641,122.596909573894,
120.965832554958,119.416137865804,118.516536815783,117.643054658187,
117.281647992718,117.328194221248,117.119095146817,117.479195348135,
119.717697802906,123.559602263005,126.777668542303,128.497005101731,
129.135167930612,127.79258494314,125.522147782669,124.187227469739,
122.987117968321,122.310801292645,121.930963285117,121.816410282942,
121.889612313365,122.879148352072,125.057498240586,127.460629717786,
130.704294359997, 136.24539694722,154.39181584582,254.888144850326,
276.932326801277,277.388325995937,278.506798594382,279.968762057109,
281.101348461141,281.369043841337,281.619184732637,282.227081687741,
283.050420058574,284.138138210954,284.797200895241,286.328746582848,
288.362726758368,290.704458912889, 292.943824332615,294.733498 374596,
296.175598342547,297.373477244996,298.387794419952,298.179840415319,
296.9674148962,295.605326053392,294.760576510127,294.785882352792,
295.935765474742,296.832512250004,297.798770744004,298.760625478154,
297.190041875953,290.467240727854,279.712395757604,268.073659209118,
258.965379766511)),.Names = c(date,hr,u,v,speed,
dir),row.names = c(NA, -170L),class =data.frame)


解决方案

原始函数中存在一个错误,如果最大速度未超过默认最大速度20,则数字中断点将转换为 1:n ,导致值不正确地落入标记较高的箱。



更改行 spd.breaks< - c(seq(spdseq)) spd.breaks< - spdseq



在您的情况下,您还需要将 spdmax = 12 作为参数,所以你的图例没有unu sed值和 spdmin = 0 ,因为您的值低于默认最小值2。

结果在改变那行代码之后:

  plot.windrose(data = wind,spd =speed,dir =dir,spdmin = 0,spdmax = 12)


I am trying to use the fantastic wind rose R code from Andy Clifton at https://stackoverflow.com/a/17266781/709777 for plotting data extracted from a meteorological model. From the model I get u and v wind components in m/s. Then I compute wind speed and direction and try wind rose code. But I'm not sure it is working as expected or maybe I don't understand what the function is doing.

My attempt uses Andy's function and the following code to plot 4 wind roses:

flist<-c("03050","12010","46070","46050")

for (i in 1:4 ) {

windfile=paste("viento-",flist[i],".csv",sep="")
viento=read.table(windfile,sep=";",header=F)
colnames(viento) <- c("u","v")
fecha=read.table("ffhh.txt",header=F,sep=";")
colnames(fecha) <- c("date","hr")

wind<-cbind.data.frame(fecha,viento)

wind$speed=sqrt(wind$u*wind$u+wind$v*wind$v)
wind$dir=windDir(wind$u,wind$v)

graf=paste("RAMS-wind-rose-",flist[i],".png",sep="")
png(graf,res=240,width=3000, height=2400)
plot.windrose(data = wind,spd = "speed",dir = "dir")
dev.off()

}

Graphical output is

So maximum wind speed is in the 18-20 m/s range from the plot. Is it right? But if I look for maximum wind speed I get a different value

max(wind$speed)
[1] 10.24317

Maybe I'm misunderstanding how wind.rose function runs or maybe there is a problem when calling the function. Any suggestion would be appreciated, I'm stuck here now.

Wind data:

dput(wind)

structure(list(date = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 5L), .Label = c("05/05/2015", "05/06/2015", "05/07/2015", 
"05/08/2015", "05/09/2015"), class = "factor"), hr = c(12L, 13L, 
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 
17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 
0L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L), u = c(1.967012, 1.520496, 2.145498, 2.36543, 
2.352827, 2.295602, 2.320738, 2.38692, 2.412154, 2.612796, 3.032838, 
3.62067, 4.216179, 4.614041, 4.746128, 4.687606, 4.449001, 4.098231, 
3.565422, 2.594458, -1.378813, -3.703259, -3.874501, -3.617813, 
-3.360489, -3.179794, -3.073682, -3.053857, -3.100727, -3.193508, 
-3.409015, -3.93074, -4.45107, -4.840204, -5.139567, -5.436072, 
-5.776207, -6.371346, -7.121193, -7.59635, -7.894677, -7.906566, 
-7.483042, -6.81692, -5.891807, -4.977591, -4.057455, -3.212969, 
-2.421152, -1.546586, -0.455518, 0.639647, 2.054146, 3.487688, 
5.05859, 7.112991, 8.424683, 9.222707, 9.661589, 9.87525, 9.978607, 
9.800485, 9.46149, 9.037914, 8.542727, 7.966156, 7.308363, 6.567787, 
5.676618, 4.929429, 4.2488, 3.619122, 3.071927, 2.662167, 2.388519, 
2.199777, 2.059402, 1.941171, 1.826771, 1.742619, 1.653258, 1.61614, 
1.66758, 1.813451, 1.983155, 1.967012, 1.520496, 2.145498, 2.36543, 
2.352827, 2.295602, 2.320738, 2.38692, 2.412154, 2.612796, 3.032838, 
3.62067, 4.216179, 4.614041, 4.746128, 4.687606, 4.449001, 4.098231, 
3.565422, 2.594458, -1.378813, -3.703259, -3.874501, -3.617813, 
-3.360489, -3.179794, -3.073682, -3.053857, -3.100727, -3.193508, 
-3.409015, -3.93074, -4.45107, -4.840204, -5.139567, -5.436072, 
-5.776207, -6.371346, -7.121193, -7.59635, -7.894677, -7.906566, 
-7.483042, -6.81692, -5.891807, -4.977591, -4.057455, -3.212969, 
-2.421152, -1.546586, -0.455518, 0.639647, 2.054146, 3.487688, 
5.05859, 7.112991, 8.424683, 9.222707, 9.661589, 9.87525, 9.978607, 
9.800485, 9.46149, 9.037914, 8.542727, 7.966156, 7.308363, 6.567787, 
5.676618, 4.929429, 4.2488, 3.619122, 3.071927, 2.662167, 2.388519, 
2.199777, 2.059402, 1.941171, 1.826771, 1.742619, 1.653258, 1.61614, 
1.66758, 1.813451, 1.983155), v = c(-2.766112, -0.478182, -0.192239, 
-0.124549, -0.263261, -0.265564, -0.47101, -1.788897, -1.908823, 
-1.305634, -0.531897, 0.247035, 0.92907, 1.397227, 1.65391, 1.787991, 
1.82894, 1.81852, 1.755265, 1.585399, 1.592519, 2.354492, 2.532527, 
2.313413, 2.016459, 1.792902, 1.670022, 1.599441, 1.599147, 1.650283, 
1.745915, 2.0444, 2.540668, 3.210907, 3.841764, 4.323583, 4.700086, 
4.940802, 5.083652, 5.159999, 5.12434, 5.00041, 4.663396, 4.229373, 
3.665845, 3.217579, 2.847133, 2.461892, 2.082835, 1.615325, 0.950391, 
0.172732, -0.249755, -0.452249, -0.756625, -1.250214, -1.653063, 
-1.854439, -1.986611, -2.139991, -2.312994, -2.468648, -2.499339, 
-2.647794, -2.835616, -3.010868, -3.093763, -3.025498, -2.79024, 
-2.552279, -2.296148, -1.938917, -1.563025, -1.275801, -1.101657, 
-1.015782, -1.001581, -0.981939, -0.963097, -0.956454, -0.849296, 
-0.603197, -0.285416, 0.060993, 0.38673, -2.766112, -0.478182, 
-0.192239, -0.124549, -0.263261, -0.265564, -0.47101, -1.788897, 
-1.908823, -1.305634, -0.531897, 0.247035, 0.92907, 1.397227, 
1.65391, 1.787991, 1.82894, 1.81852, 1.755265, 1.585399, 1.592519, 
2.354492, 2.532527, 2.313413, 2.016459, 1.792902, 1.670022, 1.599441, 
1.599147, 1.650283, 1.745915, 2.0444, 2.540668, 3.210907, 3.841764, 
4.323583, 4.700086, 4.940802, 5.083652, 5.159999, 5.12434, 5.00041, 
4.663396, 4.229373, 3.665845, 3.217579, 2.847133, 2.461892, 2.082835, 
1.615325, 0.950391, 0.172732, -0.249755, -0.452249, -0.756625, 
-1.250214, -1.653063, -1.854439, -1.986611, -2.139991, -2.312994, 
-2.468648, -2.499339, -2.647794, -2.835616, -3.010868, -3.093763, 
-3.025498, -2.79024, -2.552279, -2.296148, -1.938917, -1.563025, 
-1.275801, -1.101657, -1.015782, -1.001581, -0.981939, -0.963097, 
-0.956454, -0.849296, -0.603197, -0.285416, 0.060993, 0.38673
), speed = c(3.39418794480919, 1.59391534001653, 2.15409319694506, 
2.36870672272888, 2.3675095028426, 2.31091167734728, 2.36805305783971, 
2.98287437935442, 3.07605139180817, 2.92085314241781, 3.07912662176355, 
3.62908770080374, 4.31732977949809, 4.82095609181519, 5.02604708299514, 
5.01702719021105, 4.81026313434109, 4.48358253183333, 3.9740645765147, 
3.04051020438429, 2.10647621736634, 4.38836641577991, 4.62876344229536, 
4.29423457807535, 3.91905514350105, 3.65042291577839, 3.49807011330648, 
3.44735465087797, 3.48880768402874, 3.59470823936422, 3.83009170353009, 
4.43060811938948, 5.12513590367358, 5.80839896393705, 6.41672031330531, 
6.94580799814341, 7.4468366246511, 8.06260344150201, 8.7495661264061, 
9.1831434162002, 9.41194907391285, 9.3550994692978, 8.81720929923862, 
8.02234343939033, 6.93915047316846, 5.92699137712567, 4.95672345372566, 
4.04772553598005, 3.19377185226638, 2.2363369851212, 1.0539163634772, 
0.662559150893715, 2.06927362843608, 3.51688736574617, 5.11486208794773, 
7.22202714006788, 8.58533056628911, 9.4072986777592, 9.86371761914553, 
10.1044606012682, 10.243170354167, 10.1066180883186, 9.78603537991872, 
9.41778649884526, 9.00105008851662, 8.51615920058802, 7.93621693503511, 
7.23114542969321, 6.32530087628438, 5.55098174739226, 4.82955454238836, 
4.10578167755825, 3.4467060570861, 2.95208423448417, 2.63033670069252, 
2.42297996715883, 2.29004390725702, 2.17539629745065, 2.06510244730134, 
1.98784436847481, 1.85864620360627, 1.72503771564827, 1.69182899533493, 
1.8144764190945, 2.02051078861881, 3.39418794480919, 1.59391534001653, 
2.15409319694506, 2.36870672272888, 2.3675095028426, 2.31091167734728, 
2.36805305783971, 2.98287437935442, 3.07605139180817, 2.92085314241781, 
3.07912662176355, 3.62908770080374, 4.31732977949809, 4.82095609181519, 
5.02604708299514, 5.01702719021105, 4.81026313434109, 4.48358253183333, 
3.9740645765147, 3.04051020438429, 2.10647621736634, 4.38836641577991, 
4.62876344229536, 4.29423457807535, 3.91905514350105, 3.65042291577839, 
3.49807011330648, 3.44735465087797, 3.48880768402874, 3.59470823936422, 
3.83009170353009, 4.43060811938948, 5.12513590367358, 5.80839896393705, 
6.41672031330531, 6.94580799814341, 7.4468366246511, 8.06260344150201, 
8.7495661264061, 9.1831434162002, 9.41194907391285, 9.3550994692978, 
8.81720929923862, 8.02234343939033, 6.93915047316846, 5.92699137712567, 
4.95672345372566, 4.04772553598005, 3.19377185226638, 2.2363369851212, 
1.0539163634772, 0.662559150893715, 2.06927362843608, 3.51688736574617, 
5.11486208794773, 7.22202714006788, 8.58533056628911, 9.4072986777592, 
9.86371761914553, 10.1044606012682, 10.243170354167, 10.1066180883186, 
9.78603537991872, 9.41778649884526, 9.00105008851662, 8.51615920058802, 
7.93621693503511, 7.23114542969321, 6.32530087628438, 5.55098174739226, 
4.82955454238836, 4.10578167755825, 3.4467060570861, 2.95208423448417, 
2.63033670069252, 2.42297996715883, 2.29004390725702, 2.17539629745065, 
2.06510244730134, 1.98784436847481, 1.85864620360627, 1.72503771564827, 
1.69182899533493, 1.8144764190945, 2.02051078861881), dir = c(324.582958174723, 
287.457881896944, 275.120092612918, 273.014060101878, 276.384347431893, 
276.598861790546, 281.472746249524, 306.85002863764, 308.355818041581, 
296.551646657085, 279.947330562416, 266.096810627237, 257.573002083306, 
253.152602628538, 250.787798573866, 249.121675592407, 247.652924389215, 
246.071562949111, 243.788876501029, 238.572092345486, 139.113779336087, 
122.447759192368, 123.170217537641, 122.596909573894, 120.965832554958, 
119.416137865804, 118.516536815783, 117.643054658187, 117.281647992718, 
117.328194221248, 117.119095146817, 117.479195348135, 119.717697802906, 
123.559602263005, 126.777668542303, 128.497005101731, 129.135167930612, 
127.79258494314, 125.522147782669, 124.187227469739, 122.987117968321, 
122.310801292645, 121.930963285117, 121.816410282942, 121.889612313365, 
122.879148352072, 125.057498240586, 127.460629717786, 130.704294359997, 
136.24539694722, 154.39181584582, 254.888144850326, 276.932326801277, 
277.388325995937, 278.506798594382, 279.968762057109, 281.101348461141, 
281.369043841337, 281.619184732637, 282.227081687741, 283.050420058574, 
284.138138210954, 284.797200895241, 286.328746582848, 288.362726758368, 
290.704458912889, 292.943824332615, 294.733498374596, 296.175598342547, 
297.373477244996, 298.387794419952, 298.179840415319, 296.9674148962, 
295.605326053392, 294.760576510127, 294.785882352792, 295.935765474742, 
296.832512250004, 297.798770744004, 298.760625478154, 297.190041875953, 
290.467240727854, 279.712395757604, 268.073659209118, 258.965379766511, 
324.582958174723, 287.457881896944, 275.120092612918, 273.014060101878, 
276.384347431893, 276.598861790546, 281.472746249524, 306.85002863764, 
308.355818041581, 296.551646657085, 279.947330562416, 266.096810627237, 
257.573002083306, 253.152602628538, 250.787798573866, 249.121675592407, 
247.652924389215, 246.071562949111, 243.788876501029, 238.572092345486, 
139.113779336087, 122.447759192368, 123.170217537641, 122.596909573894, 
120.965832554958, 119.416137865804, 118.516536815783, 117.643054658187, 
117.281647992718, 117.328194221248, 117.119095146817, 117.479195348135, 
119.717697802906, 123.559602263005, 126.777668542303, 128.497005101731, 
129.135167930612, 127.79258494314, 125.522147782669, 124.187227469739, 
122.987117968321, 122.310801292645, 121.930963285117, 121.816410282942, 
121.889612313365, 122.879148352072, 125.057498240586, 127.460629717786, 
130.704294359997, 136.24539694722, 154.39181584582, 254.888144850326, 
276.932326801277, 277.388325995937, 278.506798594382, 279.968762057109, 
281.101348461141, 281.369043841337, 281.619184732637, 282.227081687741, 
283.050420058574, 284.138138210954, 284.797200895241, 286.328746582848, 
288.362726758368, 290.704458912889, 292.943824332615, 294.733498374596, 
296.175598342547, 297.373477244996, 298.387794419952, 298.179840415319, 
296.9674148962, 295.605326053392, 294.760576510127, 294.785882352792, 
295.935765474742, 296.832512250004, 297.798770744004, 298.760625478154, 
297.190041875953, 290.467240727854, 279.712395757604, 268.073659209118, 
258.965379766511)), .Names = c("date", "hr", "u", "v", "speed", 
"dir"), row.names = c(NA, -170L), class = "data.frame")

解决方案

There's a bug in the original function where if your max speed does not exceed the default max speed of 20, the numeric break points are converted to 1:n, causing values to incorrectly fall into higher-labeled bins.

Change the line spd.breaks <- c(seq(spdseq)) to spd.breaks <- spdseq.

In your case you'll also want to pass spdmax = 12 as an argument so your legend doesn't have unused values, and spdmin = 0 as you have values below the default min of 2.

Result after changing that line of code:

plot.windrose(data = wind,spd = "speed",dir = "dir", spdmin = 0, spdmax = 12)

这篇关于风玫瑰图与ggplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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