colors - R force bar colours -



colors - R force bar colours -

this question has reply here:

manually setting grouping colors ggplot2 1 reply

i beginner , self-taught r user bear me.

my info looks this:

city variable value var1 0.398847367 var2 0.975311071 var3 0.957249734 b var1 0.313723366 b var2 0.130885548 b var3 0.771616001 c var1 0.057720637 c var2 0.398434369 c var3 0.088653681 d var1 0.024273226 d var2 0.744307456 d var3 0.315222384

i trying create stack bar plot ggplot. order of colours important. code

cols <- c(var1="tomato2", var2="steelblue3", var2="darkolivegreen3") ggplot(lul4, aes(x=city, y=value, group=factor(variable)) + geom_bar(stat="identity", colour="black") + scale_fill_manual(values = cols) +

doing don't colours selected in object cols. have tried avoid cols , paste scale_fill_manual(values =values = c("darkolivegreen3", "tomato2", "steelblue3")) in first line of code, right after geom_bar command. still doesn't work , out of ideas. help hugely appreciated.

thanks jbaums, although wanted them stacked. in case, adding aes(fill= variablename) in geom_bar options key create scale_fill_manual work. thanks!

the solution had in mind 1 below bars stacked. hope helps!

d <- read.table(text='city variable value var1 0.398847367 var2 0.975311071 var3 0.957249734 b var1 0.313723366 b var2 0.130885548 b var3 0.771616001 c var1 0.057720637 c var2 0.398434369 c var3 0.088653681 d var1 0.024273226 d var2 0.744307456 d var3 0.315222384', header=t) cols <- c('violetred3', 'palegreen4', 'orangered') ggplot(d, aes(x=city, y=value, fill=factor(variable))) + geom_bar(stat="identity", colour="black") ggplot(d, aes(x=city, y=value, group=factor(variable))) + geom_bar(stat="identity", colour="black", aes(fill=variable)) + scale_fill_manual(values=cols)

r colors plot ggplot2

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -