简体   繁体   中英

R - Heatmap from sparse 2d data

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? 在此处输入图片说明

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?

"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?

我实际上最终使用了smoothScatter,它运作良好并且使用了经典的R绘图。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM