[R] barplot colour problem

Abdoulaye Sarr abdoulayesar at gmail.com
Mon Jul 18 23:12:08 CEST 2016


Thank you Marc,

The typo was causing the problem, solved now.

Regards,
Fipou

On Mon, Jul 18, 2016 at 8:38 PM, Marc Schwartz <marc_schwartz at me.com> wrote:

>
> > On Jul 18, 2016, at 1:06 PM, Abdoulaye Sarr <abdoulayesar at gmail.com>
> wrote:
> >
> > I am doing a basic bar plot which works but the color of bars positive
> > (green) and negative (brown) don’t show up from the below command:
> >
> > barplot(z, ylim=c(-2,2), col=ifelse(x>0,"brown","green »))
> >
> > any help? or other methods?
> >
> > fipou
>
>
> Presuming that the above is a direct copy and paste, your ifelse()
> statement is using 'x' to determine the color, rather than 'z'. Presumably
> a typo?
>
> This works, for example, with 'z' as a vector:
>
>   z <- seq(from = -5, to = 5)
>
>   barplot(z, col = ifelse(z > 0, "brown", "green"))
>
>
> Regards,
>
> Marc Schwartz
>
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list