0

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:

Hex bin

So,

  1. I want to have a very narrow scale, e.g. <5 points, >10 points etc.
  2. Colors like heat map, red green etc.

Any help would be appreciated!

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
NSS
  • 11
  • 3
  • 1
    Please include a sample of your data to make it easier for people to see your issue https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Amanda Jun 01 '18 at 23:36
  • 6 observations isn't a large enough sample for anyone to be able to illustrate a solution for you – camille Jun 03 '18 at 16:07
  • How do I upload my data? – NSS Jun 06 '18 at 10:09

0 Answers0