[R] barplot colour problem
Marc Schwartz
marc_schwartz at me.com
Mon Jul 18 22:38:36 CEST 2016
> 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
More information about the R-help
mailing list