davidcarslaw / openair

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

Frequency labelling appear out of plot area when using emf format. #282

Open zemega opened 2 years ago

zemega commented 2 years ago

Hello. I am using this package inside RMarkdown. When I used the format emf instead of png, I ran into an issue of frequency labeling. The problem is that, the frequency labeling continues outside the box of plot area. Below is a snippet of the code, which I believe should be enough to reproduce the error. Attached is also a png image that was save from the emf file. This problem is more sever when grouping is used, as the frequency labeling of one plot continues into another plot.

RStudio Version 1.4.1103 R-4.0.2 openair 2.9-0 devEMF 4.0-2

`

library(openair)
library(devEMF)
knitr::opts_chunk$set(dev = 'emf',fig.align='center',fig.ext="emf")
windRose(mydata)

` Picture4

zemega commented 2 years ago

This is another example when grouping is used. As you can see, the frequency labelling for the year 2005 continue on and appears in 2004 and 2002. windRose(mydata, type = "year", layout = c(4, 2),bg="white")

Picture6

Is there any way to prevent this?

zemega commented 2 years ago

I have found a solution for this issue. By changing the line below

# Line 779 in  windRose.R
mymax <- 2 * max.freq
# into
mymax <- 1 * max.freq

Is there a good reason to populate mymax to double of max.freq here? I always find it odd that the frequency labeling goes way off the circle area, when there's no other information is being given outside the circle. Perhaps at most 1.1.

davidcarslaw commented 2 years ago

Thanks. I have refined the calculation so that the maximum grid line shown is rounded up to the next interval but not beyond. I have also reduced the default average number of grid lines shown as these were often too many.

zemega commented 2 years ago

I think that as a single plot, the number of gridlines is okay. But when subjected to grouping and typing, this becomes too much. Perhaps, the default average number of gridlines can scale down according to the number of grouping and typing.