user2498193
user2498193

Reputation: 1114

Spatial plot error after changes to dataframe

I was using the following code to plot a spatial plot successfully:

colours<-(brewer.pal(7, "Blues"))
brks<-classIntervals(EDdata2$SIRt, n=7, style="fixed",fixedBreaks=c(0,1,2,5.0,10.0,20,50,120))
plot(brks, pal=colours)
brks<-brks$brks
plot(EDdata2, col=colours[findInterval(EDdata2$SIRt, brks,
                             all.inside=TRUE)], axes=F, border=FALSE)

However I made some changes to the spatialpolygonsdataframe EDdata2 by adding some extra columns and changing how SIRt is calculated (however it remains a column of numbers - they are just calculate differently)

Now when I try to run the plot code I get an error despite having made no changes to the plotting code:

Error in plot.default(...) : formal argument "axes" matched by multiple actual arguments

Whats going on here ?

Upvotes: 1

Views: 130

Answers (1)

IRTFM
IRTFM

Reputation: 263481

That means that the package author of the unnamed package you used to create EDdata2 defined a plot method for whatever class EDdata2 might be that both used the axes argument and also used the triple dot mechanism to pass arguments to plot.default without filtering out that argument. (This does suggest that the package author didn't really want you to make your own axes, so you should investigate the help page for plot.whatever to see if it offers a mechanism for passing the values you want to use for 'at' and 'labels'.) You will need to do the spadework yourself (or edit your answer to make it more complete and reproducible) to investigate.

If this code is using the plot method for the SpatialPolygons-class in package:sp then the default value for axes is already FALSE.

help("SpatialPolygons-class", package="sp")

It is of course possible to mess this up by defining "F" to be something other than "FALSE" and then using axes=F. In the current instance it might be simpler to just remove that argument from the call.

Upvotes: 1

Related Questions