diff --git a/NEWS.md b/NEWS.md index a4c7a045..9c0e7d1f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -53,6 +53,9 @@ where the formatting is also better._ i.e. cases where `las = 2` or `las = 3`. (#369 @grantmcdermott) - Better integration with the Positron IDE graphics pane. Thanks to @thomasp85 for the report and helpful suggestions. (#377 @grantmcdermott) +- Fixed a bug that resulted in y-axis labels being coerced to numeric for + `"p"`-alike plot types (including `"jitter"`) if `y` is a factor or character + (#387 @grantmcdermott). ### Internals: diff --git a/R/facet.R b/R/facet.R index d9747d4a..b1aea3aa 100644 --- a/R/facet.R +++ b/R/facet.R @@ -270,7 +270,7 @@ draw_facet_window = function( lty = get_tpar(c("lty.yaxs", "lty.axis"), 1) ) type_range_x = type %in% c("barplot", "pointrange", "errorbar", "ribbon", "boxplot", "p", "violin") && !is.null(xlabs) - type_range_y = isTRUE(flip) && type %in% c("barplot", "pointrange", "errorbar", "ribbon", "boxplot", "p", "violin") && !is.null(ylabs) + type_range_y = !is.null(ylabs) && (type == "p" || (isTRUE(flip) && type %in% c("barplot", "pointrange", "errorbar", "ribbon", "boxplot", "violin"))) if (type_range_x) { args_x = modifyList(args_x, list(at = xlabs, labels = names(xlabs))) } diff --git a/inst/tinytest/_tinysnapshot/type_j_y.svg b/inst/tinytest/_tinysnapshot/type_j_y.svg new file mode 100644 index 00000000..bcfa3aff --- /dev/null +++ b/inst/tinytest/_tinysnapshot/type_j_y.svg @@ -0,0 +1,201 @@ + + + + + + + + + + + + +Sepal.Length +Species + + + + + +5 +6 +7 +8 + + + + +setosa +versicolor +virginica + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/tinytest/test-misc.R b/inst/tinytest/test-misc.R index 17b36adf..303f414b 100644 --- a/inst/tinytest/test-misc.R +++ b/inst/tinytest/test-misc.R @@ -23,6 +23,11 @@ f = function() { } expect_snapshot_plot(f, label = "type_j") +f = function() { + set.seed(42) + tinyplot(Species ~ Sepal.Length, data = iris, type = "j") +} +expect_snapshot_plot(f, label = "type_j_y") # log axes f = function() {