Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ where the formatting is also better._

- Jittered plots now support Date/POSIXt axes. Thanks to @wachtermh for the bug
report and @vincentarelbundock for the code contribution. (#327)
- `tinyplot_add(type = "jitter")` no longer errors when layered on top of
boxplot, violin, or similar categorical plot types. (#560 @grantmcdermott)

### Internals

Expand Down
3 changes: 2 additions & 1 deletion R/align_layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ align_layer = function(settings) {
} else if (!is.null(names(xlabs_layer))) {
# Case 2: match implicit integer -> label mapping (e.g., lines added to errorbars)
if (setequal(names(xlabs_layer), names(xlabs_orig))) {
# If mappings already agree and no dodge, no realignment needed
if (identical(xlabs_layer, xlabs_orig) && is.null(settings$dodge)) return(invisible())
orig_order = xlabs_orig[names(xlabs_layer)[settings$datapoints[["x"]]]]
x_layer = settings$datapoints[["x"]]
if (is.null(settings$dodge)) {
Expand All @@ -55,4 +57,3 @@ align_layer = function(settings) {
}
}
}

212 changes: 212 additions & 0 deletions inst/tinytest/_tinysnapshot/tinyplot_add_jitter_on_violin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions inst/tinytest/test-tinyplot_add.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ f = function() {
tinyplot_add(type = "lm")
}
expect_snapshot_plot(f, label = "tinyplot_add_no_recursive_margins")


# jitter layer on top of boxplot (#559)
set.seed(42)
f = function() {
tinyplot(Sepal.Length ~ Species, data = iris, type = "violin")
tinyplot_add(type = "jitter", cex = 0.5, alpha = 0.3)
}
expect_snapshot_plot(f, label = "tinyplot_add_jitter_on_violin")
Loading