我试图映射在空间中的位置的模型/ OBS差异。 我有颜色映射到差异,但我也想尺寸映射到差异。 我目前映射大小ABS(差异),但它产生两种不同的传说,我想结合。 映射大小差异为正值负值,大点的创建小点,但我真的只想幅度代表了上/下的预测。 如果它的确与众不同,我也想秤上是离散的。 谢谢
一些测试数据:
so.df=data.frame(lat=runif(50,33,43),long=runif(50,-112,-104),diff=runif(50,-2,2))
ggplot()+
geom_point(data=so.df,aes(x=long,y=lat,color=diff,size=abs(diff)),alpha=0.8)+
scale_color_gradient2(low='red',mid='white',high='blue',limits=c(-0.6,0.6),breaks=c(-0.6,-0.4,-0.2,-0.1,0,0.1,0.2,0.6))+
guides(color=guide_legend('SWE Differences (m)'),size=guide_legend('SWE Difference\nMagnitudes (m)'))+
coord_cartesian(xlim=c(-112.5,-104.25),ylim=c(33,44))+
theme_bw()
编辑:用我用下面的(开放的建议)离散色标
so.df$cuts=cut_interval(so.df$diff,length=0.15)
ggplot()+
geom_path(data=states,aes(x=long,y=lat,group=group),color='grey10')+
geom_point(data=so.df,aes(x=long,y=lat,color=cuts,size=abs(diff)),alpha=0.8)+
coord_cartesian(xlim=c(-112.5,-104.25),ylim=c(33,44))+
scale_colour_brewer(type='div',palette='RdYlBu')+
guides(color=guide_legend('SWE Differences (m)'),size=guide_legend('SWE Difference\nMagnitudes (m))+
theme_bw()