Skip to content

Commit ffb285c

Browse files
committed
fix title_spec() for vectorized input
1 parent b842024 commit ffb285c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

R/margins.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ title_spec <- function(label, x, y, hjust, vjust, angle, gp = gpar(),
6868
# descenders or not. The same happens automatically with ascenders already.
6969
descent <- font_descent(gp$fontfamily, gp$fontface, gp$fontsize, gp$cex)
7070

71+
# This title_spec() function assumes that input is not vectorized, but sometimes
72+
# that's not the case, so we need to deal with this somehow. Taking the max of all
73+
# descent values seems the best option.
74+
if (length(descent) > 1) {
75+
descent <- max(descent)
76+
}
77+
7178
# Use trigonometry to calculate grobheight and width for rotated grobs. This is only
7279
# exactly correct when vjust = 1. We need to take the absolute value so we don't make
7380
# the grob smaller when it's flipped over.

0 commit comments

Comments
 (0)