Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
394 views
in Technique[技术] by (71.8m points)

r - Add Space Between Panels of Openair windRose Plots

I created some windrose plots using the openair package and I'm pretty happy with how they turned out but aesthetically it would be nice to have some space between panels. Here's an example:

# windrose plot----
library(openair)
data("mydata")

windRose(mydata[1:144,], ws="ws", wd="wd", 
         paddle = F, 
         type = 'weekday', 
         key.header = 'Wind Speed (m/s)',
         key.footer = "",
         annotate = F,
         angle = 30, # angle of "spokes"...sort of bins for wind direction
         cols =  'jet',
         key.position = 'right',
         dig.lab = 2,
         statistic = 'prop.count', #“prop.count” sizes bins according to the 
         # proportion of the frequency of measurements
         fontsize = 20,
         grid.line = 100,
         max.freq = 105, # maximum value for the radial limits
         key = list(header = "Wind Speed (m/s)",
                    footer = '',
                    labels = c('0 to 2', '2 to 4', 
                               '4 to 6','6 or more'),
                    breaks = c(0,2,4,6)),
         layout = c(6,1)
)

Anyone have any ideas of how to add space between the panels?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After some digging I found that this plot function utilizes trellis plots, here is a good rundown on them: https://www.stat.auckland.ac.nz/~ihaka/787/lectures-trellis.pdf

Specifically the xyplot function is used to create the trellis plot. The help documentation for ?xyplot shows that you can adjust the argument between to achieve spacing between panels. The between argument is a list containing x and y values that represent space between panels. Therefore we can adjust the above code simply by adding the argument between = list(x=0.25, y = 0.25) and can adjust x and y to our preference like this:

library(openair)
data("mydata")

windRose(mydata[1:144,], ws="ws", wd="wd", 
         paddle = F, 
         type = 'weekday', 
         key.header = 'Wind Speed (m/s)',
         key.footer = "",
         annotate = F,
         angle = 30, # angle of "spokes"...sort of bins for wind direction
         cols =  'jet',
         key.position = 'right',
         dig.lab = 2,
         statistic = 'prop.count', #“prop.count” sizes bins according to the 
         # proportion of the frequency of measurements
         fontsize = 20,
         grid.line = 100,
         max.freq = 105, # maximum value for the radial limits
         key = list(header = "Wind Speed (m/s)",
                    footer = '',
                    labels = c('0 to 2', '2 to 4', 
                               '4 to 6','6 or more'),
                    breaks = c(0,2,4,6)),
         layout = c(6,1),
         between = list(x=0.25, y=0.25)
)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...