mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 03:00:48 +01:00
(v3.1.0.9019) Fix the data labels of labels_sir_count() being placed on the wrong bars with position = "dodge" or "stack"
This commit is contained in:
1 parent
77b6cb1713
commit
054066b855
6 files changed
+37
-5
No files matched your search
@@ -160,5 +160,20 @@ test_that("test-ggplot_sir.R", {
|
||||
scale_sir_colours(aesthetics = "fill", Value4 = "S", Value5 = "I", Value6 = "R"))$data),
|
||||
"data.frame"
|
||||
)
|
||||
|
||||
# datalabels are placed on their own bar, also when dodged or stacked
|
||||
for (pos in c("fill", "stack", "dodge")) {
|
||||
built <- ggplot_build(ggplot_sir(example_isolates[, c("AMX", "CIP")], position = pos, guideline = NULL))
|
||||
bars <- built$data[[1]]
|
||||
labels <- built$data[[2]]
|
||||
bars <- bars[order(bars$x, bars$group), , drop = FALSE]
|
||||
labels <- labels[order(labels$x, labels$group), , drop = FALSE]
|
||||
expect_equal(labels$x, bars$x)
|
||||
if (pos == "dodge") {
|
||||
expect_equal(labels$y, bars$ymax)
|
||||
} else {
|
||||
expect_equal(labels$y, (bars$ymin + bars$ymax) / 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user