1

I'd like to achieve what this person has achieved without using ggplot. Any ideas?

How do I create a continuous density heatmap of 2D scatter data in R?

You can see what I get when using the solution detailed in that question.

ggplot(df,aes(x=x,y=y))+
  stat_density2d(aes(alpha=..level..), geom="polygon") +
  scale_alpha_continuous(limits=c(0,1),breaks=seq(0,1,by=0.1))+
  geom_point(colour="red",alpha=0.2)+
  theme_bw()

The heatmap is so sparse. I want it to cover much more than what it is covering now. It's terribly hard to see anything about the density. Any ideas of different ways to make density heatmaps from 2D data besides this ggplot solution? enter image description here

One idea I had was instead of using linear color labeling (see the black to white spectrum on the left, which is linear), using logarithmic scale for the density labeling. Any ideas how I could do this?

Community
  • 1
  • 1
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
  • 1
    how about jittering the points? – Raffael May 12 '14 at 21:49
  • Please be specific about *"The heatmap is so sparse. I want it to cover much more than what it is covering now. It's terribly hard to see anything about the density."* What do you want to see in areas with most or all NAs? Some solid color? Then use `geom_hex()` – smci May 12 '14 at 21:51

2 Answers2

2

"The heatmap is so sparse. I want it to cover much more than what it is covering now. It's terribly hard to see anything about the density."

Please be specific: what do you want to see in areas with most or all NAs?

smci
  • 32,567
  • 20
  • 113
  • 146
2

I actually ended up using smoothScatter, which works well and uses classic R plotting.

CodeGuy
  • 28,427
  • 76
  • 200
  • 317