Question: How to use ggplot2 to display points with gradient color
0
gravatar for dr.genetics
2.4 years ago by
dr.genetics60
dr.genetics60 wrote:

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 • 4.4k views
ADD COMMENTlink written 2.4 years ago by dr.genetics60
2
gravatar for VHahaut
2.4 years ago by
VHahaut1.1k
Belgium
VHahaut1.1k wrote:

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 ?

ADD COMMENTlink modified 2.4 years ago • written 2.4 years ago by VHahaut1.1k

Incrdibly awesome! It just worked!

ADD REPLYlink written 2.4 years ago by dr.genetics60
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 777 users visited in the last hour