问题描述
我正在尝试使用stat_density_2d函数在R中创建密度图,但是我想删除密度为空的背景色。我尝试更改密度的限制,但是当将限制从[0,5]移至[0.1,5]时,背景变为灰色而不是深蓝色。我要怎么做才能有透明的背景,并只给数据点着色?
这是我的代码:
ggplot(TEST,aes(x = X,y = Y)) +
geom_point() +
stat_density_2d(geom = "raster",aes(fill = ..density..*10e04),contour = F,h = c(5,5),n = 300) +
ggtitle("7387")+
theme(plot.title = element_text(lineheight=.8,face="bold"))+
scale_y_reverse()+
scale_fill_distiller(palette = 'Spectral',limits=c(0,5))
谢谢!