0

I'm doing a heatmap and I'm having trouble getting rid of those blue 'smudge' that are off the map. I would like to cut them off.

Here is what I did:

ggplot(dengue, aes(x=long, y=lat)) + 
  stat_density2d(aes(fill = ..level..), alpha=0.8, geom="polygon")+
  geom_point(colour="red")+
  geom_path(data=map.df,aes(x=long, y=lat,group=group), colour="grey50")+
  scale_fill_gradientn(colours=rev(brewer.pal(5,"Spectral")))+
coord_fixed()

enter image description here Any hint on what I can do?

DR15
  • 647
  • 9
  • 17
  • 1
    You could try the solution from this previous question... https://stackoverflow.com/questions/49813046/remove-gaps-in-a-stat-density2d-ggplot-chart-without-modifying-xy-limits – Andrew Gustar Oct 16 '19 at 17:11
  • 2
    Don't use `$` inside `aes` https://stackoverflow.com/questions/32543340/issue-when-passing-variable-with-dollar-sign-notation-to-aes-in-combinatio – camille Oct 16 '19 at 17:46
  • Thanks for the comments. But none of them solved the problem. The first one distorced too much the densities. – DR15 Oct 22 '19 at 12:26

0 Answers0