@@ -476,12 +476,12 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
476476 legend.key.height = el_def(" unit" , " legend.key.size" ),
477477 legend.key.width = el_def(" unit" , " legend.key.size" ),
478478 legend.text = el_def(" element_text" , " text" ),
479- legend.text.align = el_def(" character " ),
479+ legend.text.align = el_def(" numeric " ),
480480 legend.title = el_def(" element_text" , " title" ),
481- legend.title.align = el_def(" character " ),
482- legend.position = el_def(" character" ), # Need to also accept numbers
481+ legend.title.align = el_def(" numeric " ),
482+ legend.position = el_def(c( " character" , " numeric " )),
483483 legend.direction = el_def(" character" ),
484- legend.justification = el_def(" character" ),
484+ legend.justification = el_def(c( " character" , " numeric " ) ),
485485 legend.box = el_def(" character" ),
486486 legend.box.just = el_def(" character" ),
487487 legend.box.margin = el_def(" margin" ),
@@ -522,10 +522,10 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
522522 plot.caption = el_def(" element_text" , " title" ),
523523 plot.caption.position = el_def(" character" ),
524524 plot.tag = el_def(" element_text" , " title" ),
525- plot.tag.position = el_def(" character" ), # Need to also accept numbers
525+ plot.tag.position = el_def(c( " character" , " numeric " ) ), # Need to also accept numbers
526526 plot.margin = el_def(" margin" ),
527527
528- aspect.ratio = el_def(" character " )
528+ aspect.ratio = el_def(" numeric " )
529529)
530530
531531# Check that an element object has the proper class
@@ -549,12 +549,7 @@ validate_element <- function(el, elname, element_tree, call = caller_env()) {
549549 # NULL values for elements are OK
550550 if (is.null(el )) return ()
551551
552- if (eldef $ class == " character" ) {
553- # Need to be a bit looser here since sometimes it's a string like "top"
554- # but sometimes its a vector like c(0,0)
555- if (! is.character(el ) && ! is.numeric(el ))
556- cli :: cli_abort(" The {.var {elname}} theme element must be a character or numeric vector." , call = call )
557- } else if (eldef $ class == " margin" ) {
552+ if (" margin" %in% eldef $ class ) {
558553 if (! is.unit(el ) && length(el ) == 4 )
559554 cli :: cli_abort(" The {.var {elname}} theme element must be a {.cls unit} vector of length 4." , call = call )
560555 } else if (! inherits(el , eldef $ class ) && ! inherits(el , " element_blank" )) {
0 commit comments