I want to plot a pie-chart on top of a gridded data that I have managed to plot.
The data:
nasafile <- "http://eosweb.larc.nasa.gov/sse/global/text/global_radiation"
nasa <- read.table(file=nasafile, skip=13, header=TRUE)
Following this post: R plot grid value on maps, I used spplot
to plot the data using:
gridded(nasa) <- c("Lon","Lat")
spplot(nasa, "Ann")
I have been trying several functions to plot pie-charts on top of the plot, but haven't managed to do it:
If I use the floating.pie
function after plotting the map, I get an error.
floating.pie(5,2, c(3,2,5,1), radius=1)
Error in polygon(xc, yc, col = col[i], ...) :
plot.new has not been called yet
Using par(new=TRUE)
after drawing an empty plot, makes me able to draw a pie-chart,but the coordinate are based on the new plot.
Is there a way to plot a pie-chart on top of a spplot
?
I checked pieSP
, but couldn't manage to plot it either.