diff --git a/NEWS.md b/NEWS.md index 04c68f3c..e82ccb7b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -293,9 +293,8 @@ Theme fixes: integer-valued (e.g. `"$1,000"`), and place the negative sign in front of the currency symbol (e.g. `"-$1.50"` rather than `"$-1.50"`). (#618, #623 @grantmcdermott) -- Fixed `xlab = NA` / `ylab = NA` gotchas: a barplot with `xlab = NA` no longer - errors, and spineplots no longer clip their category and tick labels when - `xlab`/`ylab` are set to `NA` under a dynamic theme. (#635 @grantmcdermott) +- Fixed `xlab = NA` / `ylab = NA` gotchas for `"barplot"`, `"spineplot"`, and + `"ridge"` types. (#635, #650 @grantmcdermott) - `tinyplot_add()` (`plt_add()`) now captures its arguments unevaluated, so arguments that rely on non-standard evaluation against `data` (e.g., `plt_add(..., subset = <>)`) resolve correctly instead of erroring with diff --git a/R/tinyplot.R b/R/tinyplot.R index 3f940beb..265b8323 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -1095,9 +1095,11 @@ tinyplot.default = function( # Types that suppress the standard axes (xaxt/yaxt = "n") only because they # draw their own in the same place (e.g. spineplot category + numeric labels - # via spine_axis()). Their tick-row margin must still be reserved, else the - # self-drawn labels clip when xlab/ylab = NA makes label_extent = 0 (#635). - .self_axis = identical(type, "spineplot") + # via spine_axis(); ridge y-axis category labels via tinyAxis()). Their + # tick-row margin must still be reserved, else the self-drawn labels clip -- + # or, under las 0/1 where mar is further shifted, error -- when xlab/ylab = NA + # makes label_extent = 0 (#635, #650). + .self_axis = type %in% c("spineplot", "ridge") .dyn = c( dynmar_side(1, xlab, main = main, sub = sub, diff --git a/inst/tinytest/_tinysnapshot/ridge_ylab_na_issue650.svg b/inst/tinytest/_tinysnapshot/ridge_ylab_na_issue650.svg new file mode 100644 index 00000000..8a2d4004 --- /dev/null +++ b/inst/tinytest/_tinysnapshot/ridge_ylab_na_issue650.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + +Sepal.Width + + + + + + + + +1.5 +2.0 +2.5 +3.0 +3.5 +4.0 +4.5 + + + + + + + + + + + + + + + + + + + + + + + +setosa +versicolor +virginica + + + diff --git a/inst/tinytest/test-type_ridge.R b/inst/tinytest/test-type_ridge.R index ca8d8c77..36c24e1b 100644 --- a/inst/tinytest/test-type_ridge.R +++ b/inst/tinytest/test-type_ridge.R @@ -160,3 +160,13 @@ f = function() { tinyplot(Species ~ Sepal.Width, data = iris, type = "ridge", theme = "ridge2", bg = 0.2) } expect_snapshot_plot(f, label = "ridge_theme_bg_numeric") + +# Issue #650: ylab = NA should suppress the y-axis title without erroring. +# Ridge draws its own y-axis labels, so the tick-row margin must still be +# reserved under dynamic themes (else mar collapses and par() errors). +f = function() { + tinyplot(Species ~ Sepal.Width, data = iris, + type = "ridge", theme = "ridge", ylab = NA) +} +expect_snapshot_plot(f, label = "ridge_ylab_na_issue650") +