0

I would like a plot that looks like this:

enter image description here

Using ggplot. The one above was made from heatscatter in the LSD package.

I tried using this code:

p = ggplot(data = emr.ext.melt, aes(Date,NDVI))
p  + geom_point() +  stat_density2d(aes(fill=..level..), geom="polygon") +
    scale_fill_gradient(low="blue", high="green")+ scale_y_continuous(limits = c(-1, 1))

But, got this weird plot. I just want a scatter plot colored based on the density of points for that given day. I do not want to use hexplot either.

enter image description here Thank you for your help!

il_raffa
  • 5,090
  • 129
  • 31
  • 36
  • Can you make your [example reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Roman Luštrik Dec 11 '16 at 07:56
  • In your example, `geom_point()` simply plots the black points from your data. You want something in your `aes()` for `geom_point()` where color is a density estimate tied to a color gradient. – David Dec 12 '16 at 01:19
  • I thought I had figured this out. – Christiana A Jan 01 '17 at 21:36
  • myData <- data.frame( myDate = sample(c('04062015','04222015','05082015','05242015','06092015','06252015', '07112015','07272015','08122015','08282015','09132015','09292015'),1000, replace = T), NDVI2 = sample(seq(0,1, by =0.0001),1000,replace = T) ) myData$myDate = as.Date(myData$myDate,"%m%d%Y") heatscatter(as.vector(myData$myDate),as.vector(myData$NDVI2), colpal = "bl2gr2rd",ylim=c(0,1)) – Christiana A Jan 01 '17 at 21:37

0 Answers0