r - keep colour palette constant between plots -


i need compare 2 maps of same quantities, keep colour palette constant in 2 graphs, easing comprehension, looks don't how so.

should set limits (e.g. minimum between plots assigned low , highest level high?)

is there easy way so?

i new this, sorry if solution banal, went through lot of blog posts looks not finding anything.

my code:

fin<-get_map("helsinki",zoom=12)     ggmap(fin, legend="bottom")+         geom_polygon(data=a,aes(x=a$long,y=a$lat, id=id, fill=test_statistics), alpha=0.1, colour="white") 

to give idea, image

animage

and another

another

it not clear @ all! images still need bit of "prettyfying" give idea

basically in this question, discrete (factor) values

i can't reproduce plots because you've not given data, setting limits in scale_colour_gradient should work. see:

http://docs.ggplot2.org/0.9.3.1/scale_gradient.html

under "tweak scale limits" (second example) hadley says:

setting limits manually useful when producing multiple plots need comparable

for example (and i'm using points here simplicity - have use scale_fill_gradient set fill colour polygons - don't have time build polygons):

> set.seed(310366); d=data.frame(x=runif(20),y=runif(20),   z1=rnorm(20), z2=rnorm(20)+5) 

note z1 has range of -1 1, , z2 has range of 4 7. helps see effect.

> ggplot(d,aes(x=x,y=y,col=z1))+geom_point(size=8) +     scale_colour_gradient(limit=range(c(d$z1,d$z2))  > ggplot(d,aes(x=x,y=y,col=z2))+geom_point(size=8) +      scale_colour_gradient(limit=range(c(d$z1,d$z2))) 

produces 2 plots same limits on palette legend, first 1 has dark points because values low (-1 1) , second 1 has light colours because values high (4 7).

both sets of points have been coloured using same mapping of value colour because of limit argument in scale_colour_gradient function. mapping fill attribute think need scale_fill_gradient.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -