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

David Winsemius dwinsemius at comcast.net
Sun Mar 2 00:48:03 CET 2008


"Henrique Dallazuanna" <wwwhsd at gmail.com> wrote in
news:da79af330803011508u4cd31c96j9584ace16cca697e at mail.gmail.com: 

> This works for me:
> 
> x <- y <- seq(-4*pi, 4*pi, len=27)
> r <- sqrt(outer(x^2, y^2, "+"))
> library(lattice)
> levelplot(r, colorkey=list(col=gray((0:32)/32)),
>     col.regions=(col=gray((0:32)/32)))

Works for me as well.

> 'r' is a matrix for you?

It was the vector created by the first levelplot() example. I had not 
run the code of Megh Dal. 

When I hastily looked at the help page and saw that "colorkey" was 
supposed to be a logical, I assumed that the list argument was throwing 
the error. If I had read the full text I would have seen that a list 
argument was also valid. This gives what appears to me to be identical 
success, but maybe it has risks that I don't understand:

levelplot(r, colorkey=TRUE,
     col.regions=(col=gray((0:32)/32)))

Thanks;
David Winsemius


 
> 
> On 01/03/2008, David Winsemius <dwinsemius at comcast.net> wrote:
>> "Henrique Dallazuanna" <wwwhsd at gmail.com> wrote in
>> news:da79af330802290329y4c0ad78fkc483303229a868ae at mail.gmail.com:
>>
>> library(lattice)
>> levelplot(r, colorkey=list(col=gray((0:32)/32)),
>>      col.regions=(col=gray((0:32)/32)))
>>
>> When I try that example, I get an error, even after updating
>> lattice. 
>>
>> > levelplot(r, colorkey=list(col=gray((0:32)/32)),
>> +  col.regions=(col=gray((0:32)/32)))
>> Error in UseMethod("levelplot") : no applicable method for
>> "levelplot" 
>>
>> If I simply change colorkey=FALSE to colorkey=TRUE in the first
>> level 
> plot
>> help page example, I have what looks to me as "success".
>>
>> levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
>>           ylab="", main="Weird Function", sub="with log scales",
>>           colorkey = TRUE,
>>           region = TRUE)
>>
>> --
>> David Winsemius
>>
>> >
>> > On 29/02/2008, Megh Dal <megh700004 at yahoo.com> 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/itlWOv
>> > uuO tI/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.
>> >>  >
>> >>
>> >> > 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
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.h 
> tml
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
>



More information about the R-help mailing list