[R] barplot colors

2013-03-26 Thread Francois de Ryckel
Dear all, I have a 2 by 2 matrix and I would like to do a barplot with it. (so 2 bars with each having 2 stacks.). I would like to have one colors per stack, so 4 different colors total. The problem is that R is only given me 2 colors (the same two for the bottom stack and the same two for

Re: [R] barplot colors

2013-03-26 Thread Rui Barradas
Hello, According to the code in file src/R/graphics/barplot.R, barplot() will draw column by column, and threfore use as many colors as rows in the matrix. Those colors will be reused for all bars. So I'm not seeing an easy way of doing what you want using base graphics. Not without changing

Re: [R] barplot colors

2013-03-26 Thread David L Carlson
Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Francois de Ryckel Sent: Tuesday, March 26, 2013 1:09 PM To: r-help@r-project.org Subject: [R] barplot colors Dear all, I have a 2 by 2 matrix

Re: [R] barplot colors

2013-03-26 Thread Rui Barradas
Hello, I forgot to add that if you use argument beside = TRUE, you can have as many colors as there are bars, but this is not the kind of graph you want. (This behavior makes a lot of sense if you look at the underlying code for barplot.) Rui Barradas Em 26-03-2013 19:39, Rui Barradas

Re: [R] barplot colors

2013-03-26 Thread Francois De Ryckel
Hi David, Thanks a lot for your advice and helping me tricking barplot. It totally work. Have a great evening! François On 26 Mar 2013, at 21:43, David L Carlson wrote: You will have to trick barplot into thinking you have four groups: wmod - cbind(c(w[,1], 0, 0), c(0, 0, w[,2]))

Re: [R] barplot colors

2013-03-26 Thread Francois De Ryckel
Hi Rui, Thanks for trying. I know about the beside. The reason I want them stack with various colors is that the 4 stacks represent the number of students on each quartiles on a test. Have a terrific Tuesday! François On 26 Mar 2013, at 21:45, Rui Barradas wrote: Hello, I forgot to

[R] barplot colors

2011-07-24 Thread James Fearon
Hi, In barplot(height, col = ...), the col = vector recycles so that the same colors are used for each bar. I would like to use different colors in different bars (corresponding to another piece of information, here, the region of the country being represented). For example, x =

Re: [R] barplot colors

2011-07-24 Thread Joshua Wiley
Hi Jim, In most cases, I would highly recommend an alternative to a stacked bar plot (only 4 numbers are communicated, but an entire plot is filled). Depending on the data and your goals, simple points or lines offer easy alternatives. I have also been able to get a lot of mileage out of