[R] swap hist() colours

Rui Barradas ruipbarradas at sapo.pt
Fri Sep 14 19:27:54 CEST 2012


Hello,

Use ?colorRampPalette

nr <- nrow(yes.matrix_11)
clrs <- colorRampPalette(c("white", "black"))(nr)

barplot(yes.matrix_11, beside =TRUE, ylim=c(0,250), col = clrs)
[...etc...]

Hope this helps,

Rui Barradas

Em 14-09-2012 12:33, Robert Pazur escreveu:
> Hi,
> i created a set of graphs and want to find out how to swap the bar colours
> (from white to black) and set it to be default for all graph that i will
> produce (f.e. for different number of columns). some sugggestions?
> thanks in advance.
>
> here is an example:
> ##############################
> a <-read.table("http://www.scandinavia.sk/data/R/kotlina1.csv", sep=";",
> header=T)
> PAR_11_yes <- subset(a, a$kot_clc06  == 11)
> PAR_hist11_yes <- hist(PAR_11_yes$PAR_11_p, breaks= c(0.1*0:10),
> plot="FALSE")
> PAR_hist11_c_yes <- (PAR_hist11_yes$counts)
> LR_11_yes <- subset(a, a$kot_clc06  == 11)
> LR_hist11_yes <- hist(LR_11_yes$LR_11_p, breaks= c(0.1*0:10), plot="FALSE")
> LR_hist11_c_yes <- (LR_hist11_yes$counts)
> RK_11_yes <- subset(a, a$kot_clc06  == 11)
> RK_hist11_yes <- hist(RK_11_yes$RK_11_p, breaks= c(0.1*0:10), plot="FALSE")
> RK_hist11_c_yes <- (RK_hist11_yes$counts)
> yes.results_11 <-
> data.frame(PAR_hist11_c_yes,LR_hist11_c_yes,RK_hist11_c_yes)
> #dataframe to matrix
> yes.matrix_11<-data.matrix(yes.results_11)
> colnames(yes.matrix_11) <-c ("PAR", "LR", "RK")
> barplot(yes.matrix_11, beside =TRUE,ylim=c(0,250))
> abline(v=(6),col = "black", lty=3, xpd= F)
> abline(v=(17),col = "black", lty=3, xpd= F)
> abline(v=(28),col = "black", lty=3, xpd= F)
> f <- c(11.5,22.5)
> axis(1, f,labels = FALSE)
> box()
> ###############################
>
> Robert Pazur
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.




More information about the R-help mailing list