Adding a jitter layer on top of a boxplot or violin plot errors with a row mismatch:
Error in `[[<-.data.frame`:
! replacement has 123 rows, data has 150
Originally spotted in: joshuaulrich/microbenchmark#52 (comment). But here's a manual reprex:
library(tinyplot)
# boxplot + jitter
tinyplot(Sepal.Length ~ Species, data = iris, type = "boxplot")

tinyplot_add(type = "jitter", cex = 0.5, alpha = 0.3)
#> Error in `[[<-.data.frame`:
#> ! replacement has 123 rows, data has 150
# violin + jitter (flipped)
tinyplot(Sepal.Length ~ Species, data = iris, type = "violin", flip = TRUE)

tinyplot_add(type = "jitter", cex = 0.5, alpha = 0.3)
#> Error in `[[<-.data.frame`:
#> ! replacement has 123 rows, data has 150
Created on 2026-03-23 with reprex v2.1.1
The bug is in align_layer(). When the added layer'sxlabs mapping is identical to the original layer's, the remapping logic should be skipped. Instead, it tries to index names(xlabs_layer) with non-integer (jittered) x values, which causes names()[0] to return character(0) and silently shrink the result vector.
Hopefully a simple fix.
Adding a jitter layer on top of a boxplot or violin plot errors with a row mismatch:
Originally spotted in: joshuaulrich/microbenchmark#52 (comment). But here's a manual reprex:
Created on 2026-03-23 with reprex v2.1.1
The bug is in
align_layer(). When the added layer'sxlabsmapping is identical to the original layer's, the remapping logic should be skipped. Instead, it tries to indexnames(xlabs_layer)with non-integer (jittered)xvalues, which causesnames()[0]to returncharacter(0)and silently shrink the result vector.Hopefully a simple fix.