eliocamp / metR

Tools for Easier Analysis of Meteorological Fields
https://eliocamp.github.io/metR/
143 stars 22 forks source link

min.size for a contour to be labelled #154

Closed marmigues closed 3 years ago

marmigues commented 3 years ago

Hi Elio, In the "Visualization tools vignette" says that "Since in some datasets there can be very small contours that should not be labelled for clarity, the min.size argument specifies the minimum points a contour has to have in order to be labelled". However, min.size parameter is not available. Has the parameter name/usage changed o is it a feature for a future version? I'm working with metR v.0.11.0 in R.3.6.3

Thanks a lot for this package, I look forward to use some other features. Miguel

eliocamp commented 3 years ago

The min.size argument is there. In this example, I set it to a ridiculous high number and no contour is labelled.

library(metR)
library(ggplot2)

ggplot(temperature[lev == 300], aes(lon, lat, z = air)) +
    geom_contour_fill() +
    geom_contour(color = "black") +
    geom_text_contour(min.size = 500) +
    scale_fill_divergent() 

Created on 2021-11-10 by the reprex package (v2.0.1)

marmigues commented 3 years ago

Thanks for your response, it solved my problem. My bad is that I was trying to put contours and labels directly with geom_contour2 (which doesn't have a min.size parameter), instead of using 2 geoms (geom_contour and geom_text_contour).

eliocamp commented 3 years ago

As of the recent release, you can label contours with geom_contour2(aes(label = ..level..), but it doesn't have that functionality, since it depends on the isoband package, which doesn't have that option control over contouring.