library(RColorBrewer)
library(ggplot2)
colormap<-rev(brewer.pal(11,'Spectral'))
x1<-rnorm(mean = 2.3,7000)
y1<-rnorm(mean=1.2,7000)
df<-data.frame(x=x1,y=y1)
ggplot(df,aes(x,y))+geom_hex(bins=40,na.rm=TRUE)+#scale_fill_gradientn(colours=colormap)+theme_bw()
scale_fill_gradient2(low="Green",mid="LightGoldenrod1",high = "red",midpoint =10)+theme_bw() #自定义颜色,注意midpoint值要正确,否则颜色显示不全。
image.png
网友评论