r - Strange ggplot colour palette in reference key -


i attempting plot density of new migrant gp registrations onto local authority area map; plot has worked reasonable extent except have no idea has happened colour palette. suspect has become confused presence of decimals in fill value. if click on picture note colour key circular beginning end.

does know might have happened here, how avoid in future , resolve on occasion better key?

result of current ggplot

install.packages("rgdal") library(rgdal) install.packages("maptools") library(maptools) install.packages("rgeos") library(rgeos) myshape2 <- readshapespatial("infuse_dist_lyr_2011.shp") plot(myshape) plot(myshape2) install.packages("ggplot2") library(ggplot2) str(myshape2) myshape2frame <- fortify(myshape2, region="name") install.packages("gpclib", type = "source")  pathrtools <- paste(c("c:\\rtools\\bin",                   "c:\\rtools\\mingw_64\\bin",                   "c:\\miktex\\miktex\\bin",                   "c:\\r\\bin\\i386",                   "c:\\windows",                   "c:\\windows\\system32"), collapse=";") sys.setenv(path=paste(pathrtools,sys.getenv("path"),sep=";")) install.packages("gpclib", type = "source") library(gpclib) gpclibpermit() gpclibpermitstatus() # simplify polgons tad (tweak 0.00001 liking) myshapebuffer <- gbuffer(myshape2, byid=true, width=0) view(myshapebuffer) # deal bad polygons plot(myshapebuffer) myshape2frame <- fortify(myshapebuffer, region="name") view(myshape2frame) mig16 <- read.csv("migration.csv") library(plyr) intmig <- ggplot() + geom_map(data = mig16, aes(map_id = area, fill = mig),                  map = myshape2frame) + expand_limits(x = myshape2frame$long,    y = myshape2frame$lat)) 

i cant test exactly, think opposite (of decimal issue), fill values being treated factors instead of real numeric values. try changing fill = mig fill = as.numeric(as.character(mig)).

(remember factors have converted character, before being converted desired numeric value).


Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -