[R] plot zoo custom panel help

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jul 25 22:40:39 CEST 2008


I can't reproduce this.  Put it all in a .R file, source it into
a fresh session and see if you still get the problem.
If you do still get an error email it to me and I'll try
sourcing the file as well.

On Fri, Jul 25, 2008 at 4:28 PM, stephen sefick <ssefick at gmail.com> wrote:
> zoo 1.5-4 package version
> R 2.7.1
> Mac OS X 10.3.5 and
> Windows XP
> #from data contained in my second post
> #this works fine
> plot(d)
> plot(d[,1])
> #gives me this error message
> Error in plot.window(...) : invalid 'ylim' value
>
> I downloaded the latest version of zoo today as to out previous
> conversation.  I, also, tried the source version that you provided me (circa
> last week). The same behavior applies on both of the above operating
> systems.  As for the panel function,  everything worked fine once I was made
> aware that the function has to draw the lines.
> thanks
>
> Stephen
>
> On Fri, Jul 25, 2008 at 3:34 PM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>>
>> Please clarify what the problem is.  If its the lack
>> of content in the plot that was already addressed.
>> You mention ylim but its not clear what your
>> comment refers to since the plot command does
>> not use ylim.
>>
>> Also make sure you are using the latest version of zoo
>> and identify the version in your posts and, in general,
>> read the last line of every message to r-help and read the
>> posting guide.  Also, it would be appreciated
>> if you follow up on past advice in the thread prior to
>> reposting.
>>
>> On Fri, Jul 25, 2008 at 1:37 PM, stephen sefick <ssefick at gmail.com> wrote:
>> >
>> > I am still having the can't draw a plot without putting in a ylim value
>> > when
>> > trying to draw a plot.  I have included reproducible code sorry for the
>> > previous post
>> >
>> >>
>> >> #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(f))
>> >>   plot(f, xaxt="n", ylim=c(0,20))
>> >>   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.
>> >> >
>> >
>> >
>> >
>> > --
>> > 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
>
>
>
> --
> 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



More information about the R-help mailing list