[R] How to alter circle size

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun May 8 21:00:05 CEST 2011


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.
>



More information about the R-help mailing list