[R] colors in facet ggplot and geom_bar

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Feb 22 17:00:19 CET 2016


By failing to provide a reproducible example and framing the desired answer as 'any hint' you are effectively limiting yourself to 'any hint' rather than a working example. 

The 'any hint' is that err_type should be a factor with levels in your desired order, and you can then use any of the scale_fill_* functions including scale_colour_manual to specify the colors in the same order as the levels in the factor. 
-- 
Sent from my phone. Please excuse my brevity.

On February 22, 2016 7:24:17 AM PST, efisio solazzo <efisio.solazzo at jrc.ec.europa.eu> wrote:
>Dear,
>I wonder if there is a way to 'play' with colors in facet ggplot and 
>geom_bar.
>
>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
>
>
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list