Here is one way using quantile() to calculate the appropriate percentiles for you. I add tags with rug() .
set.seed(1) X <- rnorm(200) boxplot(X, yaxt = "n")
Refresh . In response to the OP output containing str() , here is an example similar to the data that the OP should execute:
set.seed(1) ## make reproducible HWD <- data.frame(Hour = rep(0:23, 10), Houston_Load = rnorm(24*10))
Now, suppose you want ticks at the 85th and 90th percentiles for each Hour ? If so, we need to split the data into Hour and compute via quantile() , as I showed earlier:
quants <- sapply(split(HWD$Houston_Load, list(HWD$Hour)), quantile, probs = c(0.85, 0.9))
which gives:
R> quants <- sapply(split(HWD$Houston_Load, list(HWD$Hour)), + quantile, probs = c(0.85, 0.9)) R> quants 0 1 2 3 4 5 6 85% 0.3576510 0.8633506 1.581443 0.2264709 0.4164411 0.2864026 1.053742 90% 0.6116363 0.9273008 2.109248 0.4218297 0.5554147 0.4474140 1.366114 7 8 9 10 11 12 13 14 85% 0.5352211 0.5175485 1.790593 1.394988 0.7280584 0.8578999 1.437778 1.087101 90% 0.8625322 0.5969672 1.830352 1.519262 0.9399476 1.1401877 1.763725 1.102516 15 16 17 18 19 20 21 85% 0.6855288 0.4874499 0.5493679 0.9754414 1.095362 0.7936225 1.824002 90% 0.8737872 0.6121487 0.6078405 1.0990935 1.233637 0.9431199 2.175961 22 23 85% 1.058648 0.6950166 90% 1.145783 0.8436541
Now we can draw marks in x places of boxes
boxplot(Houston_Load ~ Hour, data = HWD, axes = FALSE) xlocs <- 1:24 ## where to draw marks tickl <- 0.15 ## length of marks used for(i in seq_len(ncol(quants))) { segments(x0 = rep(xlocs[i] - 0.15, 2), y0 = quants[, i], x1 = rep(xlocs[i] + 0.15, 2), y1 = quants[, i], col = c("red", "blue"), lwd = 2) } title(xlab = "Hour", ylab = "Houston Load") axis(1, at = xlocs, labels = xlocs - 1) axis(2) box() legend("bottomleft", legend = paste(c("0.85", "0.90"), "quantile"), bty = "n", lty = "solid", lwd = 2, col = c("red", "blue"))
The resulting figure should look like this:
