[R] colors in facet ggplot and geom_bar

efisio solazzo efisio.solazzo at jrc.ec.europa.eu
Mon Feb 22 16:24:17 CET 2016

I wonder if there is a way to 'play' with colors in facet ggplot and 

With reference to the attached figure, I'd like to
- color the green portion based on a numerical variable (say 1 to 10) on 
all of the four panels and
- color-code the y labels based on the values of the 'bias' (red portion 
of bars) only on the fourth panel.

the code to produce the plot is:

ggplot(Data, aes(x=mod_names, y=value, 
fill=err_type))+geom_bar(stat='identity', position='stack')  +
   facet_wrap(~spec_comp, nrow=1, 
scales="free")                                +
   theme(axis.text.x = element_text(angle = 90, vjust = 0.5, 
hjust=1.))        +
   theme(axis.title.x = element_blank())+ ylab(units) +
   geom_text ( aes(label=sign.value, y=pos))  +....

where err_type = c('bias', mMSe', 'var')

thanks for any hint.

Efisio SOLAZZO, Ph.D.
European Commission, Joint Research Centre,
Institute for Environment and Sustainability,
TP123, Via E. Fermi, 2749 I-21027 Ispra (VA), Italy
Tel: +390332789944 Fax: +390332785837

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex.png
Type: image/png
Size: 53928 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160222/1b8d0e5e/attachment.png>

More information about the R-help mailing list