[R] density plot on a log scale

John Kane jrkrideau at inbox.com
Thu Jun 14 17:27:10 CEST 2012


Would something like ggplot's transparacy option help?
Example bascially from http://had.co.nz/ggplot2/geom_point.html

# Plot large data set.
d <- ggplot(diamonds, aes(carat, price)) + geom_point()
d

# plot large data set with transparancy set to 1/10 th 
p = ggplot(diamonds, aes(carat, price))  + geom_point(alpha = 1/10) 
p







http://had.co.nz/ggplot2/geom_point.html

John Kane
Kingston ON Canada


> -----Original Message-----
> From: jim at bitwrit.com.au
> Sent: Thu, 14 Jun 2012 21:39:36 +1000
> To: field.cady at gmail.com
> Subject: Re: [R] density plot on a log scale
> 
> On 06/14/2012 07:08 PM, field.cady wrote:
>> I'm working with a large dataset - large enough that when I do a scatter
>> plot
>> the points all blur together, so I want to plot their density by color -
>> a
>> heat map or something like that.  I've used smoothScatter for tasks like
>> this, but the problem is that my current dataset really only looks good
>> on a
>> log-log scale.  When I do the following command
>> 
>> smoothScatter(
>>          data,
>>          xlim=c(100,100000000),
>>          ylim=c(100,10000000000),
>>          log="xy",
>>          pch="."
>> )
>> 
>> the output seems to only show a few of the points, and they are in odd
>> places that don't seem to correlate at all with the colors.  I got a
>> warning
>> that I should increase the gridsize, but even using comically large
>> values
>> (nbin=10000) didn't help.  Does anybody know how I can do this?  Thanks!
>> 
> Hi field.cady,
> This is a very rough example (I haven't bothered to do the log
> transformation or anything and the matrix is upside down), but it might
> get you where you want to go.
> 
> x<-runif(1000)
> y<-runif(1000)
> xydens<-matrix(0,10,10)
> xybreaks<-seq(0,1,length.out=11)
> for(row in 1:10) {
>   for(column in 1:10)
>    xydens[row,column]<-
>    sum(x>=xybreaks[row] & x < xybreaks[row+1] &
>    y >= xybreaks[column] & y < xybreaks[column+1])
> }
> library(plotrix)
> color2D.matplot(xydens)
> 
> Jim
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
Publish your photos in seconds for FREE
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4



More information about the R-help mailing list