[R] help plotting multiple ts

Mark Myatt mark at myatt.demon.co.uk
Fri Sep 21 14:25:44 CEST 2001


All,

My first time with the ts objects and functions (and low-level plot
functions) and I need a little help. I have some food security data
(proportion of HHs with stocks until the end of a given month) and want
to plot that. Here is what I have:

        WheatI     <- c(0.00, 0.00, 0.97, 0.97, 0.87, 0.74, 0.64, 0.51,
        0.28, 0.26, 0.18, 0.00, 0.00, 0.00, 0.00, 0.00)
        WheatR     <- c(0.00, 0.00, 0.79, 0.51, 0.38, 0.13, 0.00, 0.00,
        0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00)
        BarleyI    <- c(0.00, 0.00, 0.41, 0.31, 0.31, 0.21, 0.05, 0.03,
        0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00)
        BarleyR    <- c(0.00, 0.00, 0.33, 0.18, 0.13, 0.10, 0.03, 0.03,
        0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00)
        Potatoes   <- c(0.00, 0.00, 0.00, 0.00, 0.00, 0.62, 0.59, 0.59,
        0.59, 0.51, 0.51, 0.15, 0.15, 0.13, 0.05, 0.03)
        Vegetables <- c(0.00, 0.00, 0.16, 0.16, 0.16, 0.21, 0.19, 0.19,
        0.19, 0.16, 0.14, 0.06, 0.05, 0.05, 0.04, 0.01)
        Fodder     <- c(0.00, 0.09, 0.16, 0.19, 0.17, 0.18, 0.15, 0.13,
        0.12, 0.09, 0.06, 0.01, 0.01, 0.01, 0.00, 0.00)

        df <- cbind(WheatI, WheatR, BarleyI, BarleyR, Potatoes,
        Vegetables, Fodder)
        
        x <- ts(df, start = c(2001, 4), frequency = 12)
        
        plot(x, ylim = c(0,1))

I have a few questions:

        1. How do I get year and month labels on the x-axis (more
        generally I am having trouble setting the number of ticks to the
        number of periods). At present I get base 10 rather than base 12
        labels.

        2. How do I get them to plot in seven horizontal panes one above
        the other (i.e. a single column of plot)?

        3. How can I change the number of ticks and take out the first
        and last y-axix tick labels.

        4. is there a simple way of changing the y-axis labels So that
        (e.g.) WheatI becomes (irrigated Wheat)?

I have tried RTFM-input but have confused myself.

Running:

        platform i386-pc-mingw32
        arch     x86            
        os       Win32          
        system   x86, Win32     
        status                  
        major    1              
        minor    3.0            
        year     2001           
        month    06             
        day      22             
        language R              

Thanks,

Mark


--
Mark Myatt


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list