[R] How to create interrupted boxplot

Helios de Rosario helios.derosario at ibv.upv.es
Mon Mar 12 19:05:00 CET 2012


Jianghong wrote:
> Hello,
> 
> I have created two boxplots with following R code. There is one
outlier in
> B group.
> The outlier is 33. But the all other data are between 0 to 4.
> 
> How can I skip y-axis around 5 to 25, and expand 0-4 for this case.
Also I
> want keep the outlier in my boxplot.
> I want my boxplot look like the second one, keep the outlier, and
make an
> interrupt of y-axis from 5 to 25.
> 
> Thanks,
> Jianghong
> 
> 
> Example = c( 0.00,0.33,0.75,3.00,2.50,0.50,2.00,33.00)
> Grp_Example =c("A","A","A","B","B","B","B","B")
> 
> Example_Data= cbind(Example,Grp_Example)
> attach(Example_Data)
> 
> 
> boxplot(Example ~ Grp_Example,main=paste("Boxplot of Example"),
> pars = list(boxwex = 0.25, staplewex = 0.25, outwex = 0.25))
> 
> boxplot(Example ~ Grp_Example,main=paste("Boxplot of
Example"),ylim=c(0,4),
> pars = list(boxwex = 0.25, staplewex = 0.25, outwex = 0.25))

Try plotting in two regions of the same device. Quick and dirty
example:

par(mfrow=c(2,1))
boxplot(Example ~ Grp_Example,main=paste("Boxplot of Example"),
pars = list(boxwex = 0.25, staplewex = 0.25, outwex = 0.25),
ylim=c(25,35),xaxt="n")
boxplot(Example ~ Grp_Example,
pars = list(boxwex = 0.25, staplewex = 0.25, outwex = 0.25),
ylim=c(0,4))

See  ?layout --instead of par(mfrow) -- and ?par for further
adjustments of region sizes and margins.

Helios

INSTITUTO DE BIOMECÁNICA DE VALENCIA
Universidad Politécnica de Valencia • Edificio 9C
Camino de Vera s/n • 46022 VALENCIA (ESPAÑA)
Tel. +34 96 387 91 60 • Fax +34 96 387 91 69
www.ibv.org

  Antes de imprimir este e-mail piense bien si es necesario hacerlo.
En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
de Datos de Carácter Personal, le informamos de que el presente mensaje
contiene información confidencial, siendo para uso exclusivo del
destinatario arriba indicado. En caso de no ser usted el destinatario
del mismo le informamos que su recepción no le autoriza a su divulgación
o reproducción por cualquier medio, debiendo destruirlo de inmediato,
rogándole lo notifique al remitente.



More information about the R-help mailing list