[R] Lines connecting the boxes in a boxplot

Arne Brutschy abr-r-project at xylon.de
Mon Jun 18 09:55:50 CEST 2007


Hi,

C> I' recommend to save the information of your boxplots
C> Then you have the information that you need about your boxplot
C> (e.g. the value of the median) and can use segments() to draw
C> the lines you want.
Thanks, works like a charm!

Regards,
Arne

C> Arne Brutschy writes:
 >> Hello,
 >> 
 >> I'm currently using a boxplot to visualize data for three different
 >> models. As I have three models, I'm plotting three parallel boxplots
 >> for each factor.
 >> 
 >> This works fine - what I need now is a line connecting the medians of
 >> each boxplot of each model. I want to do this in order to visualize
 >> the trend that one of the models exhibit. Basically, I want to plot a
 >> curve for each model (slightly offset on the x axis), with a boxplot
 >> on each datapoint.
 >> 
 >> It's only an idea, and I don't know if it's not too confusing after
 >> adding the lines... Is it possible? Has anyone done this before?
 >> 
 >> Sorry if this has been asked before or is a standard feature, I simply
 >> have now clue how to name the feature I want. Ergo: I cannot search
 >> for it.. :\
 >> 
 >> Regards,
 >> Arne
 >> 
 >> PS: this is my current code
 >> 
 >> require(gplots)
 >> boxwex=0.15
 >> 
 >> data <- read.table("all_runs_fitness.data");
 >> colnames(data)=c("model","matrix","fitness")
 >> 
 >> boxplot(fitness ~ matrix,
 >>         data=data, boxwex=boxwex, at=(1:7 - 0.2),
 >>         main="Fitness for Matrix/Models", xlab="Matrixtype",
 >>         ylab="Fitness", ylim=c(20,100), 
 >>         subset=(model=="dyn"), col="lightblue", xaxt="n", whisklty=1)
 >> boxplot(fitness ~ matrix,
 >>         data=data, boxwex=boxwex, at = 1:7, add=TRUE, 
 >>         subset=(model=="dl3"), col="mistyrose", xaxt="n", whisklty=1)
 >> boxplot(fitness ~ matrix,
 >>         data=data, boxwex=boxwex, at=(1:7 + 0.2), add=TRUE, 
 >>         subset=(model=="dl4"), col="lightcyan", xaxt="n", whisklty=1)
 >> 
 >> axis(1, 1:8-0.5, labels=FALSE)
 >> axis(1, 1:7, tck=FALSE, labels=levels(data[,2]))
 >> 
 >> smartlegend(x="left", y="bottom", inset = 0.01,
 >>             c("dyn","dl3","dl4"), fill = c("lightblue", "mistyrose", "lightcyan"))
 >> 
 >> ______________________________________________
 >> R-help at stat.math.ethz.ch 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