Question: How to use ggplot2 to display points with gradient color
0
gravatar for dr.genetics
22 months ago by
dr.genetics50
dr.genetics50 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 • 3.1k views
ADD COMMENTlink written 22 months ago by dr.genetics50
2
gravatar for VHahaut
22 months 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 22 months ago • written 22 months ago by VHahaut1.1k

Incrdibly awesome! It just worked!

ADD REPLYlink written 22 months ago by dr.genetics50
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: 1767 users visited in the last hour