diff --git a/R/tinyplot.R b/R/tinyplot.R index a3c5894f..5a132265 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -1521,7 +1521,8 @@ tinyplot.default = function( staplewex_xx = ifelse(!is.null(dots[["staplewex"]]), dots[["staplewex"]], 0.5) outwex_xx = ifelse(!is.null(dots[["outwex"]]), dots[["outwex"]], 0.5) at_xx = unique(xx) - if (!is.null(by) && isFALSE(facet_by) && length(split_data)>1) { + x_by = !is.null(by) && identical(xlvls, lgnd_labs) + if (!is.null(by) && isFALSE(x_by) && isFALSE(facet_by) && length(split_data)>1) { boxwex_xx_orig = boxwex_xx boxwex_xx = boxwex_xx / length(split_data) - 0.01 at_xx = at_xx + seq(-((boxwex_xx_orig-boxwex_xx)/2), ((boxwex_xx_orig-boxwex_xx)/2), length.out = length(split_data))[i] diff --git a/inst/tinytest/_tinysnapshot/boxplot_groups_x_same.svg b/inst/tinytest/_tinysnapshot/boxplot_groups_x_same.svg new file mode 100644 index 00000000..9e011631 --- /dev/null +++ b/inst/tinytest/_tinysnapshot/boxplot_groups_x_same.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + +Species +setosa +versicolor +virginica + + + + + + + +Species +Sepal.Length + + + + + + +setosa +versicolor +virginica + + + + + + + + + +4.5 +5.0 +5.5 +6.0 +6.5 +7.0 +7.5 +8.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/tinytest/test-barplot.R b/inst/tinytest/test-boxplot.R similarity index 90% rename from inst/tinytest/test-barplot.R rename to inst/tinytest/test-boxplot.R index e0bb6f8b..142f9a5b 100644 --- a/inst/tinytest/test-barplot.R +++ b/inst/tinytest/test-boxplot.R @@ -47,6 +47,12 @@ f = function() { } expect_snapshot_plot(f, label = "boxplot_groups_argpass") +# don't dodge if by (groups) and x are the same +f = function() { + plt(Sepal.Length ~ Species | Species, iris, type = "boxplot") +} +expect_snapshot_plot(f, label = "boxplot_groups_x_same") + # ## facets