# Re: [R] Fwd: Re: How to create following chart for visualizing multivariate time series

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sat, 15 Mar 2008 19:28:48 +0000 (UTC)

Megh Dal <megh700004_at_yahoo.com> wrote in news:450810.95514.qm_at_web58113.mail.re3.yahoo.com:

> Thanks David, It is working. Holtman's also gave me a solution but,
> I wanted to have a color pallet for description of colors, that was
> not in his solution.

His second posting did:
<https://stat.ethz.ch/pipermail/r-help/2008-March/155785.html>

>
> However I need one small modification. If I want to plot only lower
> diagonal elements of 'dat' then how should I proceed? What I want
> is, to visualize only lower diagonal elements and having the color
> pallet on them only. Also upper diagonal element should be black
> only, irrespective of their value, as given in :
> http://bp0.blogger.com/_k3l6qPzizGs/RvDVglPknRI/AAAAAAAAAKo/itlWOvuuO
> tI/s1600-h/pairwise_kl_window60.png

This seems to do what is requested. You would not want to attempt to "blank out" the above-diagonal entries inside the levelplot function, but rather directly work on the matrix data points. You will probably need to work on prettying up the axis labels within levelplot, since they are not properly labeled:

dat = matrix(rnorm(200*200), 200, 200)
#now set all values above the diagonal to minimum

dat[row(dat) > col(dat)] <- min(dat)

# use reversed row.values to reverse the row plotting order.

colkey <- colorRampPalette(c('red','blue'))(32) levelplot(tdat, colorkey=list(col=colkey),

col.regions=(col=colkey), row.values=200:1)

Above diagonal matrix elements are now all very "red".

```--
David Winsemius

>
> Previously I tried with image() function [however there is also no

> option to put a color pallet :( ], there is a option 'zlim' to trim
> the not-required values. Is there any option in levelplot() function
> as well? I already gone through it's help file, however got nothing
> on that
>
> Megh Dal <megh700004_at_yahoo.com> wrote: Date: Sat, 15 Mar 2008
> 00:58:02 -0700 (PDT) From: Megh Dal <megh700004_at_yahoo.com>
> Subject: Re: How to create following chart for visualizing
> multivariate time series To: r-help_at_stat.math.ethz.ch
>
>  Let me take an artifical matrix :
>
>   dat = matrix(rnorm(200*200), 200, 200)
>
>   My goal is to visualize this matrix according to the procedure,
>   described in previous mails. I took Mendelssohn's advice and got
>
>   ?plot.im
>   Z <- setcov(owin())
>   plot(Z) .................... etc
>
>   However I can not reproduce this example in my problem. How I can
>   change my data matrix 'dat' to 'Z' ?
>
>   If anyone show me some light it would be great for me.
>
>   Regards,
>
> Megh Dal <megh700004_at_yahoo.com> wrote:
>
>
>
> Roy Mendelssohn <Roy.Mendelssohn_at_noaa.gov> wrote:  Date: Thu, 28 Feb
> 2008 20:55:23 -0800 From: Roy Mendelssohn <Roy.Mendelssohn_at_noaa.gov>
> Subject: Re: [R] Fwd: Re: How to create following chart for
> visualizing multivariate time series
> To: Megh Dal <megh700004_at_yahoo.com>
>
> What you are after is a colorbar. There is a colorbar option in the
>
>   http://tolstoy.newcastle.edu.au/R/help/05/02/12896.html
>
>
>
>
>   HTH,
>
>
>   Roy M.
>
>     On Feb 28, 2008, at 8:38 PM, Megh Dal wrote:
>
>     Hi Jim, i think you could not get my  point. I did not want to
>     put red-blue color there. I want to put a pallet which will
>     describe the values of r. please have a look on following :
>     http://bp0.blogger.com/_k3l6qPzizGs/RvDVglPknRI/AAAAAAAAAKo/itlWO
>     vuuOtI/s1600-h/pairwise_kl_window60.png. Please see how a color
>     pallate is added on the right side of this plot describing the
>     value of red color, value of blue color etc.
>
>
>     Is there any solution?
>
>
>     Regards,
>
>
>   jim holtman <jholtman_at_gmail.com> wrote:
>     Try something like this:
>
>
>   require(grDevices) # for colours
>   x <- y <- seq(-4*pi, 4*pi, len=27)
>   r <- sqrt(outer(x^2, y^2, "+"))
>   image(x, y, r, col=gray((0:32)/32))
>   colors <- colorRampPalette(c('red', 'yellow', 'blue')) # create
>   you color spectrum
>   image(x,y,r, col=colors(100))
>
>
>
>
>   On Thu, Feb 28, 2008 at 9:28 PM, Megh Dal wrote:
>     I used ?image function to do that, like below :
>
>
>   require(grDevices) # for colours
>   x <- y <- seq(-4*pi, 4*pi, len=27)
>   r <- sqrt(outer(x^2, y^2, "+"))
>   image(x, y, r, col=gray((0:32)/32))
>
>
>   However my next problem to add a color pallet for color
>   description [as shown in following link]. If anyone here tell me
>   how to do that, it will be good for me.
>
>
>   Regards,

>
>   Megh Dal wrote: Hi all,

>
>
>   Can anyone here please tell me whether is it possible to produce a
>   chart displayed in http://www.datawolf.blogspot.com/ in R for
>   visualizing multivariate time series? If possible how?
>

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help