Hello, I am searching for the best method to plot two variables with points whose output color depends on the size of a third variable. For example, the darkness of the x-y point would increase incrementally based on the size of the z value, similar to the colramp parameter in geneplotter. This would be analagous to symbols(), except changing the selection from the color gradient rather than the size of the plotted shape. The closest I have come so far is the levelplot() function, as below: graphdata <- alldata[,c("x","y", "size")] levelplot(size ~ x * y, data=graphdata) However, since I only have 147 total observations, the graph produced by levelplot() is mostly white space. Is there either a function that would produce this in a more visually digestible form, or a parameter I can use with levelplot to accomplish this? Thanks very much Jason
hadley wickham
2008-Aug-14 19:43 UTC
[R] Graphing: plot 3rd variable based on color gradient
On Thu, Aug 14, 2008 at 2:30 PM, Jason Pare <jay.pare at gmail.com> wrote:> Hello, > > I am searching for the best method to plot two variables with points > whose output color depends on the size of a third variable. For > example, the darkness of the x-y point would increase incrementally > based on the size of the z value, similar to the colramp parameter in > geneplotter. This would be analagous to symbols(), except changing the > selection from the color gradient rather than the size of the plotted > shape. The closest I have come so far is the levelplot() function, as > below: > > graphdata <- alldata[,c("x","y", "size")] > levelplot(size ~ x * y, data=graphdata) > > However, since I only have 147 total observations, the graph produced > by levelplot() is mostly white space. Is there either a function that > would produce this in a more visually digestible form, or a parameter > I can use with levelplot to accomplish this?install.packages("ggplot2") library(ggplot2) qplot(x, y, data=graphdata, colour = size) qplot(x, y, data=graphdata, size = size) qplot(x, y, data=graphdata, full = size, geom="tile") Learn more at http://had.co.nz/ggplot2 Hadley -- http://had.co.nz/