This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to use ggplot2 to display points with gradient color

A typical scatter plot can display a point with (x, y), as we all know. What I want to do is to associate each point with a gradient color for a 3rd dimension variable varying from 0 to 1. For example, with 1 represented with full red and 0 with no red at all for the 3rd dimension.

r

1 answer

Something like:

ggplot(data, aes(period, freq, size=copies, color=total_len)) + 
   geom_point() + 
   scale_color_gradient(low="blue", high="red")

from: http://stackoverflow.com/questions/17497479/ggplot-color-fill-and-size-in-geom-point

and using your 0-1 numerical value as the color argument ?

Incrdibly awesome! It just worked!

Log in to answer this question.