Re: [R] plot zoo custom panel help

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri, 25 Jul 2008 12:51:21 -0400

BB.zoo is missing so I can't run it but note that the panel funtion must draw the points or lines or whatever or else there will be nothing in the plot. See the examples in ?plot.zoo and in vignette("zoo-faq")

On Fri, Jul 25, 2008 at 12:13 PM, stephen sefick <ssefick_at_gmail.com> wrote:
> #the below code is the way that I would like the plot to look. I have tried
> to write a panel function:
> my.panel <- function(x, y, ..., pf = parent.frame()) {
> axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3)
> }
> #but it does not work and I am at a loss and help would be appreciated. I
> will use this for multiple
>
> library(zoo)
> library(chron)
>
> #this is what I would like the plot to look like
> f <- structure(c("12", "16", "16", "17", "19", "14", "15", "14", "14",
> "13", "15", "14", "13", "13", "13", "13", "13", "14", "15", "16",
> "15", "14", "13"), .Names = c("3", "6", "8", "10", "12", "14",
> "16", "18", "20", "22", "1", "4", "5", "7", "9", "11", "13",
> "15", "17", "19", "21", "23", "2"), index = structure(c(2006.08333333333,
> 2006.25, 2006.33333333333, 2006.41666666667, 2006.5, 2006.58333333333,
> 2006.66666666667, 2006.75, 2006.83333333333, 2006.91666666667,
> 2007, 2007.08333333333, 2007.16666666667, 2007.25, 2007.33333333333,
> 2007.41666666667, 2007.5, 2007.58333333333, 2007.66666666667,
> 2007.75, 2007.83333333333, 2007.91666666667, 2008), class = "yearmon"),
> class = "zoo")
>
> n <-
> c("f","m","a","m","j","j","a","s","o","n","d","j","f","m","a","m","j","j","a","s","o","n","d","j")
>
> rng <- range(time(BB.zoo))
> plot(f, xaxt="n")
> axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3)
>
>
>
>
> #this is data for a multiple plot. I would like this to look like the
> above, and I have tried the examples but i just can't figure out panel
> writing
> d <- structure(c("12", "16", "16", "17", "19", "14", "15", "14", "14",
> "13", "15", "14", "13", "13", "13", "13", "13", "14", "15", "16",
> "15", "14", "13", "3.0", "2.6", "2.5", "2.4", "2.5", "2.3", "2.5",
> "3.0", "2.6", "2.6", "2.6", "2.9", "2.8", "2.7", "3.0", "2.8",
> "2.7", "2.7", "2.7", "2.7", "2.8", "2.7", "2.7"), .Dim = c(23L,
> 2L), .Dimnames = list(c("3", "6", "8", "10", "12", "14", "16",
> "18", "20", "22", "1", "4", "5", "7", "9", "11", "13", "15",
> "17", "19", "21", "23", "2"), c("Alkalinity", "Chloride")), index =
> structure(c(2006.08333333333,
> 2006.25, 2006.33333333333, 2006.41666666667, 2006.5, 2006.58333333333,
> 2006.66666666667, 2006.75, 2006.83333333333, 2006.91666666667,
> 2007, 2007.08333333333, 2007.16666666667, 2007.25, 2007.33333333333,
> 2007.41666666667, 2007.5, 2007.58333333333, 2007.66666666667,
> 2007.75, 2007.83333333333, 2007.91666666667, 2008), class = "yearmon"),
> class = "zoo")
>
> my.panel <- function(x, y, ..., pf = parent.frame()) {
> axis(side=1, at = seq(rng[1], rng[2], 1/12), labels = n, tcl = -0.3)
> }
>
> plot(d, panel=my.panel ,xaxt="n")
>
>
> --
> Let's not spend our time and resources thinking about things that are so
> little or so large that all they really do for us is puff us up and make us
> feel like gods. We are mammals, and have not exhausted the annoying little
> problems of being mammals.
>
> -K. Mullis
>
> [[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 Fri 25 Jul 2008 - 16:54:04 GMT

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 Fri 25 Jul 2008 - 18:32:24 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