Re: [R] Stacked barplot of timeseries data

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Wed, 04 Jun 2008 01:47:50 +0200 (CEST)

On Tue, 3 Jun 2008, Demetri S. Mouratis wrote:

> Hi,
>
> I'm trying to plot time-series data where each sample breaks down the
> percentage of CPU time spent in each of four states (usr, nice, sys, idle)
>
>
> 19:08:15 %usr %nice %sys %idle
> 19:08:16 5 0 10 86
> 19:08:17 17 0 14 69
> 19:08:18 5 0 8 87
> 19:08:19 10 0 10 81
> 19:08:20 3 0 7 90
> 19:08:21 4 0 8 88
> [on and on for many samples]
>
> The plot I'm aiming for would stack the first three states in a colored
> barplot, so you get a visual sense of how busy the system is over the course
> of the day, and which state the CPU is spending its time in. (I've done this
> as area charts as well).
>
> barplot() looked promising, but it wants to stack the columns instead of the
> rows.
>
> Anybody have a good solution for this?

The "zoo" package provides a barplot() method for "zoo" series.

Example with some artificial data:

   library("zoo")
   x <- matrix(runif(44), ncol = 4)
   colnames(x) <- c("%usr", "%nice", "%sys", "%idle")    z <- zoo(x, Sys.time() - c(10:0))
   barplot(z, legend = TRUE)

hth,
Z

> Thanks!
> ...Demetri
>
> ______________________________________________
> 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 Tue 03 Jun 2008 - 23:50:21 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 Wed 04 Jun 2008 - 00:30:34 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