AustralianAntarcticDivision / SOmap

Southern Ocean round maps
https://australianantarcticdivision.github.io/SOmap/
24 stars 6 forks source link

still plotting when nullifying required fields (bathymetry) #63

Closed grwhumphries closed 5 years ago

grwhumphries commented 5 years ago

Describe the bug When trying to get an SOmap() object to NOT plot (as an example in a course) by nullifying the bathymetry field, if there is an existing plot in the plot window, it will still plot.

To Reproduce Steps to reproduce the behavior:

mymap <- SOmap()
temp <- mymap
temp$coastline <- NULL
temp$ice <- NULL
plot(temp)

The above produces image

If you continue with that object in the plot window and type in the console:

temp <- mymap
temp$bathy <- NULL
plot(temp)

Instead of getting an expected error, you get:
image

Seems like if there's an existing plot in the plotting window, it just plots anyways.

raymondben commented 5 years ago

Ahahahaha. Yes, you are right. The plotting code uses the bathy layer to set up a new plot in the graphics device. If the bathy layer is missing BUT there is an existing plot, then it just plots over the top. If there was no existing plot, it'd throw an error. I've updated the explanation and added an example of plotting without showing any bathymetry, just by setting the raster values to NA (thanks to @Maschette for pointing that one out). https://github.com/SCAR/EGABIcourse19/commit/6d47789bf7af1372ae3adf2649fedd8b3cdbe802

Maschette commented 5 years ago

Actually upon playing with this there is actually a better way. If you do as I suggested you get a constant warning:

Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

A better (and easier) option would be to set to color scale to NA: temp$bathy[[1]]$plotargs$col<-NA