rplotopenairrose-plot

Plot wind rose in R?


I have a simple Frequency and mean wind speed in 12 sector. How do I plot this data as wind rose (I do not want to use plot_ly) !

DF = structure(list(Sector = c("0-N", "1-NNE", "2-ENE", "3-E", "4-ESE", "5-SSE", 
                               "6-S", "7-SSW", "8-WSW", "9-W", "10-WNW", "11-NNW"), 
                    A_parameter = c(4.84, 5.04, 5.05, 4.7, 4.41, 4.66, 5.76, 
                                    7.44, 6.92, 4.87, 4.39, 4.13), 
                    k_Parameter = c(2.24, 2.271, 2.115, 1.959, 1.779, 1.943, 2.01,
                                    2.393, 2.326, 1.971, 1.908, 1.904), 
                    frequency = c(0.057, 0.08, 0.086, 0.071, 0.05, 0.041, 
                                  0.071, 0.178, 0.182, 0.089, 0.051, 0.045), 
                    mean_WS = c(4.287, 4.464, 4.473, 4.167, 3.924, 4.132, 5.104, 
                                6.595, 6.131, 4.317, 3.895, 3.665)), 
               .Names = c("Sector", "A_parameter", "k_Parameter", 
                          "frequency", "mean_WS"), 
               row.names = c("3", "4", "5", "6", "7", 
                             "8", "9", "10", "11", "12", "13", "14"), 
               class = "data.frame")

In plot_ly it is going to be like :

plot_ly(DF, r = ~(DF$frequency*DF$mean_WS), t = ~DF$Sector)%>% add_area()

What are my alternatives here ?


Solution

  • Here's a ggplot2 solution. I placed grid lines on top of the wind rose bars to match the plotly look, but you can turn that off:

    DF$Sector <- factor(DF$Sector, levels = DF$Sector)
    ggplot(DF,
           aes(x = Sector, y = frequency * mean_WS)) +
      geom_col(width = 1, fill = "steelblue", color = "steelblue") +
      coord_polar(start = -pi/12) + # change start value if you want a different orientation
      theme_light() +
      theme(axis.title = element_blank(),
            panel.ontop = TRUE, # change to FALSE for grid lines below the wind rose
            panel.background = element_blank())
    

    plot