In my boxplot, I needed to modify the whisker definition for only one level of the factor plotted on the x-axis, and used the method given in this answer, which involves splitting the data into two separate frames and plotting them separately. This has the unwanted side effect of obliterating the ordering on the levels of the factor; they are now in the default (alphabetical) ordering.
How can I preserve the level ordering in the original data frame?
Example:
library(ggplot2)
data(diamonds)
# This function extends the whiskers to the full range of the data, rather than
# the default IQR-based range
no.outliers = function(x) {
setNames(quantile(x, c(0.00, 0.25, 0.50, 0.75, 1.00)),
c("ymin", "lower", "middle", "upper", "ymax"))
}
ggplot(diamonds, aes(x=cut, y=price)) +
geom_boxplot(data=subset(diamonds, cut != 'Ideal')) +
stat_summary(data=subset(diamonds, cut == 'Ideal'), geom="boxplot",
fun.data=no.outliers)