teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
533 stars 32 forks source link

how elem_list_rect function accept named vector or list to be used as parameters? #102

Closed junjunlab closed 1 year ago

junjunlab commented 1 year ago

Hi, I am comming again. I want to used a named vector or list to the elem_list_rect() function, but I found the doesn't work:

column_strip_setting_list = c(color = "red",fill = "white")
# or
column_strip_setting_list = list(color = "red",fill = "white")

background_x = elem_list_rect(column_strip_setting_list)
teunbrand commented 1 year ago

The function accepts key = value arguments, not a list of arguments. To programmatically call the function with arguments in a list, you can do do.call(elem_list_rect, column_strip_setting_list). This isn't really any different to how most functions in R work with ellipsis (...), so I don't think this is a bug.