MagicForrest / DGVMTools

R package for processing, analysing and visualising ouput from Dynamic Global Vegetation Models (DGVMs)
GNU General Public License v3.0
29 stars 22 forks source link

Improve automatic axis limits in plotSpatialComparison() #92

Closed hol430 closed 3 months ago

hol430 commented 3 months ago

Previously, if the data being plotted contained NA values, and limits were not explicitly passed into this function, the automatically-calculated axis limits would be NA, which would cause the plots to render as monotone grey, and no scale would be drawn.

The solution is to call max(..., na.rm = TRUE), which tells the max() function to ignore NA values. In practice, users should carefully consider how to handle NA values on their end, but it doesn't hurt here to do the best we can with the data we've been given.

As always, I'm happy to discuss if you'd rather take a different approach here.

MagicForrest commented 3 months ago

In general NAs should no be present in Field objects, but if course they can happen, so it is good to catch them here. Thanks Drew.