davidcarslaw / openair

Tools for air quality data analysis
https://davidcarslaw.github.io/openair/
GNU General Public License v2.0
305 stars 113 forks source link

How can I adjust the windRose legend? #360

Open spencer-tassone opened 1 year ago

spencer-tassone commented 1 year ago

I am working on making a wind rose figure using the openair package. How can I increase the legend text font size, legend title font size, and left-align the legend title?

library(openair)

dd <- data.frame(
  datetime = seq.POSIXt(as.POSIXct('2022-05-07 00:00:00'),
                        as.POSIXct('2022-05-07 23:00:00'),
                        '1 hour'),
  windDir_deg = c(290, 272, 290, 272, 298, 295, 298, 289, 314, 337, 335, 320, 331, 351, 359, 7, 289, 341, 348, 279, 354, 278, 156, 173),
  windgust_ms = c(3.5, 1.4, 3.4, 2.6, 4.3, 20.4, 13.3, 12.5, 17.6, 2.9, 18.0, 5.2, 6.9, 7.3, 7.1, 7.0, 5.6, 5.9, 5.7, 5.1, 5.0, 2.7, 4.5, 4.2)
)

windRose(dd, ws = 'windgust_ms', wd = 'windDir_deg',
         breaks = c(0,1,2,3,5,8,11,14,17,21),
         cols = c('gray95','#ffffcc','#ffeda0','#fed976','#feb24c',
                  '#fd8d3c','#fc4e2a','#e31a1c','#b10026'),
         annotate = F,
         paddle = F,
         key.position = 'right',
         key.header = expression(Wind~Speed~(m~s^-1)),
         key.footer = NULL,
         key.cex.labels = 2.5)

Created on 2023-08-15 with reprex v2.0.2

UPDATE: UPDATE: I was able to increase the font size of the legend text and title using fontsize = but still unsure how to left-align the legend title.

windRose(dd, ws = 'windgust_ms', wd = 'windDir_deg',
         breaks = c(0,1,2,3,5,8,11,14,17,21),
         cols = c('gray95','#ffffcc','#ffeda0','#fed976','#feb24c',
                  '#fd8d3c','#fc4e2a','#e31a1c','#b10026'),
         annotate = F,
         paddle = F,
         key.position = 'right',
         key.header = expression(Wind~Speed~(m~s^-1)),
         key.footer = NULL,
         fontsize = 15)
rs028 commented 1 year ago

@spencer-tassone this may be relevant https://github.com/davidcarslaw/openair/issues/100