Re: [R] How to alter circle size

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon, 09 May 2011 00:30:05 +0530

On Fri, May 6, 2011 at 10:21 PM, Dat Mai <dat.d.mai_at_gmail.com> wrote:
> Hello all,
>
> I'm trying  to create a heatmap using 2 matrices I have: z and v. Both
> matrices represent different correlations for the same independent
> variables. The problem I have is that I wish to have the values from matrix
> z to be represented by color intensity while having the values from matrix v
> to be represented by circle size. I currently have the following in front of
> me and an unsure of what to add or change in order to achieve that goal.
>
> panel.corrgram.2 =
> function(x, y, z, subscripts, at = pretty(z), scale = 0.8, ...)
> {
>  require("grid", quietly = TRUE)
>  x <- as.numeric(x)[subscripts]
>  y <- as.numeric(y)[subscripts]
>  z <- as.numeric(z)[subscripts]
>  zcol <- level.colors(z, at = at, ...)
>  for (i in seq(along = z))
>  {
>    lims <- range(0, z[i])
>    tval <- 2 * base::pi * seq(from = lims[1], to = lims[2], by = 0.01)
>    grid.polygon(x = x[i] + .5 * scale * c(0, sin(tval)),
>      y = y[i] + .5 * scale * c(0, cos(tval)),
>      default.units = "native",
>      gp = gpar(fill = zcol[i]))
>    grid.circle(x = x[i], y = y[i], r = .5 * scale,
>      default.units = "native")
>  }
> }

Probably this modification

panel.corrgram.2 <-

    function(x, y, z, v, subscripts, at = pretty(v), scale = 0.8, ...) {

    require("grid", quietly = TRUE)

    x <- as.numeric(x)[subscripts]
    y <- as.numeric(y)[subscripts]
    z <- as.numeric(z)[subscripts]

    zcol <- level.colors(v, at = at, ...)

    <Rest unchanged>

followed by

levelplot(signif(z,3), v = v, panel = panel.corrgram.2, ...)

will do it.

-Deepayan

>
> k=levelplot(signif(z,3), scales = list(x = list(rot = 45)),
> col.regions=col.sch, panel = panel.corrgram.2,
> label = num.circ, xlab="", ylab="", main=paste(output,"receptor response"))
> print(k)
>
> --
> Best,
> Dat Mai
> PhD Rotation Student
> Albert Einstein College of Medicine
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



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. Received on Sun 08 May 2011 - 19:02:44 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 09 May 2011 - 15:10:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive