Re: [R] Multiple barplots on the same axis

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Fri 13 Oct 2006 - 14:09:02 GMT

On Thu, 2006-10-12 at 23:08 -0300, Andre Nathan wrote:
> Hi
>
> R newbie here :)
>
> I need to plot 3 barplots in the same axis, something like
>
> |
> | _ _ _
> | | | _ | | _ | | _
> | _ | || | _ | || | _ | || |
> | | || || | | || || | | || || |
> -+-----------------------------------------
> | v1 v2 v3
>
>
> Is there any documentation describing how to achieve that, and what data
> file layout would make the job easier?
>
> Thanks in advance,
> Andre

There are examples in ?barplot, where the VADeaths data is used. The key is the use of 'beside = TRUE', to enable grouped bars:

barplot(VADeaths, beside = TRUE,

        col = c("lightblue", "mistyrose", "lightcyan",
                "lavender", "cornsilk"),
        legend = rownames(VADeaths), ylim = c(0, 100))

To see what the VADeaths data set looks like:

 > VADeaths

See ?barplot for more information.

There is also an R Graphics Gallery with code at:

http://addictedtor.free.fr/graphiques/index.php

and From Data to Graphics at:

http://zoonek2.free.fr/UNIX/48_R/03.html

Both of which are helpful.

HTH, Marc Schwartz



R-help@stat.math.ethz.ch 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 Sat Oct 14 00:16:45 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 13 Oct 2006 - 14:30:09 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.