animation - Clearing plotted points in R -
i trying use animation package generate "evolving" plot of points on map. map generated shapefiles (from readshapespatial/readshapelines functions).
the problem when it's plotted in loop, result additive, whereas ideal result have evolve.
are there ways of using par() missing?
my question is: there way clear points ploted points function , not clearing entire figure not having regraph shapefiles?
in case wants see code:
# plotting underlying map newyork <- readshapespatial('nycpolygon.shp') routes <- readshapelines('nyc.shp') par(bg="grey25") plot(newyork, lwd=2, col ="lightgray") plot(routes,add=true,lwd=0.1,col="lightslategrey") # plotting points , save gif ani.options(interval=.05) savegif({ par(bg="grey25") # begin loop (i in 13:44){ infile <-paste("week",i,".csv",sep='') mydata <-read.csv(file = infile, header = true, sep=",") plotvar <- var$para nclr <- 4 plotclr <-brewer.pal(nclr,"rdpu") class<- classintervals(plotvar,nclr,style = "pretty") colcode <- findcolours(class,plotclr) points(var$lon,var$lat,col=colcode) } })
if can accept residual shadow or halo of ink, can over-plot color ="white" or == background choices. cannot access shape file can try out adding line:
points(var$lon, var$lat, col="grey25")
it may leave gaps in other plotted figures or boundaries, because it's not object-oriented. lattice , ggplot2 graphics models more object oriented, if want post reproducible example, might alternate path "moving" forward. seem remember rgl package has animation options in repetoire.
Comments
Post a Comment