[R] How to use color shade in Stacked bar plot?

Jim Lemon jim at bitwrit.com.au
Tue Jul 24 10:53:02 CEST 2012


On 07/24/2012 02:34 AM, Manish Gupta wrote:
> Hi,
>
> I am wokring on stacked R plot but i want to use shade color of red for each
> stack and corresponding legend. How can i use it?
>
Hi Manish,
I think what you want is a series of reds that you can use to 
distinguish the bars in a stack. The series will be repeated in each 
stack of the plot. If this is the case, maybe this will help:

library(plotrix)
# assume you have five bars in each stack
# first use saturation - deep red to pink
myreds1<-color.scale(1:5,1,c(0,0.7),c(0,0.7))
# then try brightness - bright red to dark red
myreds2<-color.scale(1:5,c(1,0,5),0,0)
# finally use different red colors
myreds3<-color.scale(1:5,1,c(0,0.3),c(0.3,0))

Jim



More information about the R-help mailing list