1

How can I change the y axis to exclude outliers (not just hide them but scale the y axis so as not to include them) for geom_boxplot with multiple individual boxplots using facet_wrap? An example of my dataset is:

Pop.  grp1  grp2    grp3  grp4   grp5   grp6    grp7    grp8
a  0.00652  1.27    0.169 0.859  0.388  0.521   3.58   0.0912 
a  0.0133   0.136   0.154 0.167  0.845  0.159   0.561  0.108  
a  0.0270   1.60    0.119 0.515  0.0386 0.0145  0.884  0.0155 
b  0.00846  0.331   0.100 0.897  0.330  2.52    0.663  0.0338 
b  0.0154   0.0997  0.122 0.0873 0.905  0.136   0.413  0.139  
b  0.0353   0.536   0.171 0.471  0.0280 0.00608 0.414  0.00973

where I'd like to make a boxplot for each column showing populations a and b.

I've melted the data by population and then used geom_boxplot + facet_wrap but some outliers are so far above the whiskers that the boxes themselves barely show. The code I've used is:

wc.m <- melt(w_c_diff_ab, id.var="Pop.") 
p.wc <- ggplot(data = wc.m, aes(x=variable, y=value)) + geom_boxplot(aes(fill=Population))
p.wc + facet_wrap( ~ variable, scales="free") + scale_fill_manual(values=c("skyblue", violetred1"))

but I'm struggling to remove outliers as I'm not sure how to calculate limits for the y axes on a per-boxplot basis.

Axeman
  • 32,068
  • 8
  • 81
  • 94
CWills
  • 11
  • 2
  • It is probably better to not hide any data, but perhaps use a transformation on the y-axis. – Axeman Jan 04 '18 at 15:01

0 Answers0