boxplot of different colors
Hi Elaine, Without a reproducible example it's impossible to say, but I'd take a hard look at: table(obs.group) If that doesn't give you some insight, a small reproducible example included in your email using dput() would allow us to answer you more effectively. Sarah
On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo <elaine.kuo.tw at gmail.com> wrote:
Hello,
I am making a boxplot of 13 boxes.
I tried to color the box using 13 colors but failed.
Only red and brown were displayed.
Green, blue, and grey disappeared.
Please kindly advise modification after checking the code below.
Thank you in advance.
Elaine
R code
# data input
dataN
<-read.csv("H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv",header=T,
row.names=1)
dim(dataN)
dataN[1,]
str(dataN)
# graph
par(mai=c(1,1.03,0.4,0.4))
obs.group<-dataN$Diet_B
par(new=T)
boxplot(GE_distance~Diet_B, data=dataN,xlab="Diet of Breeding
Ground",ylab="",
yaxt="n",type="p",
pch=1,lwd=0.95,
cex.lab=1.4, cex.axis=1.2,
font.axis=2,
cex=1.5,
las=1,
bty="l",
col=c("forestgreen", "darkgreen","chocolate1","darkorange2","sienna2",
"red2","firebrick3",
"saddlebrown","coral4","chocolate4","darkblue","navy","grey38")[obs.group]))
op = par(mar = c(5,5,4,2) + 0.1)
title(ylab = "Distance between Centers of B and NB Range (1000 km)",
cex.lab = 1.4,line = 3)
axis(side=2,yaxp=c(0,20000,4),cex.lab=1.4, cex.axis=1.2,font.axis=2,
las=1)
Sarah Goslee http://www.functionaldiversity.org