Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate auto-detecting limits (e.g., colour bar limits, "x" limits) #34

Closed
jack-davison opened this issue Mar 29, 2023 · 3 comments · Fixed by #48
Closed

Investigate auto-detecting limits (e.g., colour bar limits, "x" limits) #34

jack-davison opened this issue Mar 29, 2023 · 3 comments · Fixed by #48
Assignees
Labels
enhancement New features map:polar 🧭 Anything to do with polar marker maps, e.g., polarMap()

Comments

@jack-davison
Copy link
Collaborator

hat tip to @mooibroekd

This is a note to look into the feasibility of auto-detecting colour and radial axis scales (for example, for polarMap() and annulusMap()).

It would be a nice QOL feature if a user could write polarMap(polar_data, upper = "auto", limits = "auto") and appropriate scales would be set for all markers. Scales would be taken to be the max value.

Notes:

  • Would take longer - would need to create one set of plots, determine the scales, and then plot the markers.
  • Wouldn't necessarily need to create all the markers in the first instance - could just use type in the {openair} function.
  • Would probably mean bumping up "upper" to be an explicit polarMap() arg.
@jack-davison jack-davison added enhancement New features map:polar 🧭 Anything to do with polar marker maps, e.g., polarMap() ggmap 📊 labels Mar 29, 2023
@jack-davison jack-davison self-assigned this Mar 29, 2023
@mooibroekd
Copy link

It seems that the ggopenair::polarMap() and ggmaps::polarMap() differ in how scales are handled. From what I have seen is that ggopenair::polarMap() does it the same way as openair::polarMap() (i.e., calculating the maximum scales for each panel for the legend and radial axis), whereas ggmaps::polarMap() seems to be the odd one out with having parameters (limits and upper) to achieve such look.

@jack-davison
Copy link
Collaborator Author

The defaults for {openairmaps} are to consider each marker individually, so that bright red on marker 1 doesn't necessarily equal bright red on marker 2. When training I call this "qualitative mode" as its a good default to help triangulate sources, where the actual value doesn't matter as much as identifying where the highest concentrations are pointing at.

However, having to manually set the limits is a faff, so we can make it easier for people to switch to "qualitative mode" and have all markers share an appropriate scale.

In the auto-detect-limits branch I've started implementing the feature for {openairmaps} in the following way:

polarMap() and polarAnnulus() (and the static equivalents) can have the following "limit" values:

  • "free" (the default) which lets all markers have separate color scales.
  • "fixed" which forces them all to use the same color scale (taking the conc. range of all markers, as {openair} does)
  • Some numeric value, e.g., c(0, 100), to set it manually

A similar option is given for upper, which will default to "fixed" instead. I think it does make sense to put all markers on the same "x" scale, so this is a sensible change in the default behaviour to how it works now.

NB: currently doesn't work on diffMap() due to {openair} limitations.

Still need to:

  • Check & bug fix
  • See if there are similar approaches for the other mapping functions that could be included.

@jack-davison
Copy link
Collaborator Author

Turning attention back to this.

I think the implementation for polarMap() and annulusMap() are both solid (limits for both, and upper for polarMap().

For the others, their scales are binned rather than continuous, but I reckon we could still automate them through the use of pretty():

  • percentileMap() - the interval argument could be easily automated by getting the range of the pollutant value. NB: would need to promote interval to an explicit argument rather than have it in the ....
  • freqMap() - the breaks argument could again be automated in a similar way to polarMap() (i.e., create the polarFreq() separately and pull out the weights)
  • pollutionRose() is more challenging, but it could just be a case of extracting the intervals attribute from a shared plot for breaks.
  • windRose() I don't think is needed; the breaks and ws.int have defaults in openair so there is no situation where "free" or "fixed" will be needed.

I think my rule of thumb for the default is colour scales should default to "free" whereas axis scales should default to "fixed".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features map:polar 🧭 Anything to do with polar marker maps, e.g., polarMap()
Projects
None yet
2 participants