Reputation: 1
My ggmap() code to overlay contour plots on a Stamen Map works perfectly until I put it inside a function. Then it stops displaying the map, although all the parameters etc are correctly passed. Here's the code:
ggmap(stamenMapObject) +
scale_fill_brewer(palette = "RdYlGn", direction = -1) +
geom_contour_filled(data = df, alpha = 0.5, aes(x = lon, y = lat, z = z),
breaks = myBreaks)
Any thoughts on what might be wrong? Some kind of scoping issue I've missed in R?
Weirdly, the code works if I put a Debug breakpoint at the ggmap call inside the function, then inside Debug Execute the Next Line using CMD-Enter, or copy and paste the code into the Console. So clearly all the parameters, packages etc are set correctly.
But inside Debug it DOES NOT WORK if I try to execute it using (Mac) F10 or 'c' or 'n' in the console.
¯_(ツ)_/¯
Upvotes: 0
Views: 43