@@ -476,12 +476,12 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
476
476
legend.key.height = el_def(" unit" , " legend.key.size" ),
477
477
legend.key.width = el_def(" unit" , " legend.key.size" ),
478
478
legend.text = el_def(" element_text" , " text" ),
479
- legend.text.align = el_def(" character " ),
479
+ legend.text.align = el_def(" numeric " ),
480
480
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 " )),
483
483
legend.direction = el_def(" character" ),
484
- legend.justification = el_def(" character" ),
484
+ legend.justification = el_def(c( " character" , " numeric " ) ),
485
485
legend.box = el_def(" character" ),
486
486
legend.box.just = el_def(" character" ),
487
487
legend.box.margin = el_def(" margin" ),
@@ -522,10 +522,10 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
522
522
plot.caption = el_def(" element_text" , " title" ),
523
523
plot.caption.position = el_def(" character" ),
524
524
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
526
526
plot.margin = el_def(" margin" ),
527
527
528
- aspect.ratio = el_def(" character " )
528
+ aspect.ratio = el_def(" numeric " )
529
529
)
530
530
531
531
# Check that an element object has the proper class
@@ -549,12 +549,7 @@ validate_element <- function(el, elname, element_tree, call = caller_env()) {
549
549
# NULL values for elements are OK
550
550
if (is.null(el )) return ()
551
551
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 ) {
558
553
if (! is.unit(el ) && length(el ) == 4 )
559
554
cli :: cli_abort(" The {.var {elname}} theme element must be a {.cls unit} vector of length 4." , call = call )
560
555
} else if (! inherits(el , eldef $ class ) && ! inherits(el , " element_blank" )) {
0 commit comments