I am very amateur with respect to R and ggplot. I have a dataset containing green and blue fluorescence intensity. I plotted them as a scatter plot green vs blue in ggplot using hex bin. There are lots of overlapping points, which I would like to color based on the number of overlapping points e.g. <5 points = red, >10 = green etc. kind of heat map with manual color scheme.
I used this script:
ggplot(newData_cut)+
geom_hex(aes(x=green, y=blue, fill=(..count..))) +
theme_bw() +
scale_x_continuous() +
scale_y_continuous() +
scale_fill_gradient(low = "lightblue", high = "darkblue")
In addition, if I reduce the binwidth, lot of the points are lost. Could you please help me? This is the kind of data that I have:
> head(newData_cut)
green blue
1 0.09949 0.953093
2 0.00000 0.049440
3 0.00000 0.048830
4 0.00000 0.047304
5 0.00000 0.044862
6 0.00000 0.043947
This is the image that I get:
So,
- I want to have a very narrow scale, e.g. <5 points, >10 points etc.
- Colors like heat map, red green etc.
Any help would be appreciated!