diff --git a/NEWS.md b/NEWS.md index 8f45e6ab..ba0e3ad1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -240,6 +240,9 @@ Theme fixes: arguments that rely on non-standard evaluation against `data` (e.g., `plt_add(..., subset = <>)`) resolve correctly instead of erroring with "object not found". (#638 @grantmcdermott) +- `plt(..., ann = FALSE)` correctly turns off title annotations now, fixing a + regression that we missed from at least v0.6.0. Thanks to @bastistician for + the report. (#641 @zeileis) ## v0.6.1 diff --git a/R/tinyplot.R b/R/tinyplot.R index d21be892..d4026f66 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -1244,9 +1244,12 @@ tinyplot.default = function( } } - draw_title(main, sub, cap, xlab, ylab, legend, legend_args, opar, - xlab_line_offset = if (!is.null(dynmar_computed)) .whtsbp_x_raw else 0, - ylab_line_offset = if (!is.null(dynmar_computed)) .whtsbp_y_raw - max(0, .ymgp_shift) - .ylab_cex_shift else 0) + ann = as.logical(ann) + if (ann) draw_title( + main, sub, cap, xlab, ylab, legend, legend_args, opar, + xlab_line_offset = if (!is.null(dynmar_computed)) .whtsbp_x_raw else 0, + ylab_line_offset = if (!is.null(dynmar_computed)) .whtsbp_y_raw - max(0, .ymgp_shift) - .ylab_cex_shift else 0 + ) } diff --git a/inst/tinytest/_tinysnapshot/ann_FALSE.svg b/inst/tinytest/_tinysnapshot/ann_FALSE.svg new file mode 100644 index 00000000..7d7beccb --- /dev/null +++ b/inst/tinytest/_tinysnapshot/ann_FALSE.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + +-1.0 +-0.5 +0.0 +0.5 +1.0 + + + + + + +-1.0 +-0.5 +0.0 +0.5 +1.0 + + + + + + + + + + + + diff --git a/inst/tinytest/test-misc.R b/inst/tinytest/test-misc.R index 4433c3d0..586bc6bf 100644 --- a/inst/tinytest/test-misc.R +++ b/inst/tinytest/test-misc.R @@ -148,3 +148,9 @@ f = function() { tinyplot(Sepal.Length ~ 1, data = iris, xlab = "My X", ylab = "My Y") } expect_snapshot_plot(f, label = "formula_y1_cust_lab") + +# ann = FALSE turns off titles (#626) +f = function() { + plt(0, 0, ann = FALSE) +} +expect_snapshot_plot(f, label = "ann=FALSE") \ No newline at end of file