Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/plot-render.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ table_add_tag <- function(table, label, theme) {
if (location %in% c("plot", "panel")) {
if (!is.numeric(position)) {
hjust <- try_prop(element, "hjust", default = 0.5)
vjust <- try_prop(element, "vjust", default = 0.5)
if (right || left) {
x <- (1 - hjust) * width
if (right) {
Expand All @@ -288,7 +289,6 @@ table_add_tag <- function(table, label, theme) {
x <- unit(hjust, "npc")
}
if (top || bottom) {
vjust <- try_prop(element, "vjust", default = 0.5)
y <- (1 - vjust) * height
if (top) {
y <- unit(1, "npc") - y
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ test_that("plot.tag.position rejects invalid input", {

})

test_that("left and right plot tags can be rendered inside plot regions", {
p <- ggplot(mtcars, aes(mpg, disp)) + geom_point() + labs(tag = "Fig. A)")

for (position in c("left", "right")) {
for (location in c("plot", "panel")) {
expect_no_error(
ggplotGrob(
p + theme(
plot.tag.position = position,
plot.tag.location = location
)
)
)
}
}
})

test_that("position axis label hierarchy works as intended", {
df <- data_frame(foo = c(1e1, 1e5), bar = c(0, 100))

Expand Down
Loading