From 97f08206d5ebb40c27813b8109aa9f2c26f597be Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Fri, 21 Nov 2025 10:23:51 -0800 Subject: [PATCH 1/3] sort factors regardless for grouped cases --- R/tinyplot.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/tinyplot.R b/R/tinyplot.R index 6c764633..b186ddf9 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -1217,6 +1217,7 @@ tinyplot.default = function( datapoints[[dp_var]] } ) + datapoints = datapoints[order(datapoints[[dp_var]]), ] } else if (!is.null(names(labs_layer))) { # case 2: match implicit integer -> label mapping (e.g., lines added to errorbars) if (setequal(names(labs_layer), names(labs_orig))) { From 68660d53598aeebde54d8509fb9bec862c449d14 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Fri, 21 Nov 2025 10:26:53 -0800 Subject: [PATCH 2/3] update news --- NEWS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2b6bf2b0..853c89bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -40,10 +40,10 @@ where the formatting is also better._ axis limits for secondary plot layers. (#513 @grantmcdermott) - Fixed lazy evaluation bug where `legend` passed as a symbol through S3 methods (e.g., `tinyplot.foo`) would fail. (#515 @grantmcdermott) -- Added layers, particularly from `tinyplot_add()`, should now respect the x-axis - order of the original plot layer. This should ensure that we don't end up with - misaligned layers. For example, when adding a ribbon on top of an errorbar - plot. (#517 @grantmcdermott) +- Added layers, particularly from `tinyplot_add()`, should now respect the + x-axis order of the original plot layer. This should ensure that we don't end + up with misaligned layers. For example, when adding a ribbon on top of an + errorbar plot. (#517, #520 @grantmcdermott) ### Documentation From 2204c691a107f7db8958cce235b69bfe4801b89b Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Fri, 21 Nov 2025 10:35:22 -0800 Subject: [PATCH 3/3] add test --- .../pointrange_with_layers_grouped.svg | 98 +++++++++++++++++++ inst/tinytest/test-type_pointrange.R | 12 +++ 2 files changed, 110 insertions(+) create mode 100644 inst/tinytest/_tinysnapshot/pointrange_with_layers_grouped.svg diff --git a/inst/tinytest/_tinysnapshot/pointrange_with_layers_grouped.svg b/inst/tinytest/_tinysnapshot/pointrange_with_layers_grouped.svg new file mode 100644 index 00000000..0b41a534 --- /dev/null +++ b/inst/tinytest/_tinysnapshot/pointrange_with_layers_grouped.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + +model +Model A +Model B +Model C + + + + + + + +term +estimate + + + + + + + +(Intercept) +wt +cyl +hp + + + + + + +0 +10 +20 +30 +40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/tinytest/test-type_pointrange.R b/inst/tinytest/test-type_pointrange.R index 06d8dd80..d2f14477 100644 --- a/inst/tinytest/test-type_pointrange.R +++ b/inst/tinytest/test-type_pointrange.R @@ -94,3 +94,15 @@ fun = function() { type = type_pointrange(dodge = 0.2)) } expect_snapshot_plot(fun, label = "pointrange_dodge_01") + +# issue #519 layer on top of grouped plots +# (don't care about dodge yet; revist when #493 resolved) + +fun = function() { + tinyplot(estimate ~ term | model, + ymin = conf.low, ymax = conf.high, + data = results, + type = type_pointrange()) + tinyplot_add(type = 'l') +} +expect_snapshot_plot(fun, label = "pointrange_with_layers_grouped") \ No newline at end of file