nbarrowman / vtree

An R package for calculating and drawing variable trees
https://nbarrowman.github.io/vtree
75 stars 6 forks source link

Custom color palette #37

Open kellytdunn opened 8 months ago

kellytdunn commented 8 months ago

Is there a way to use a custom color palette, defined with hex codes, in vtree? (not part of RColor Brewer). Love this tool. Thanks!

mac471 commented 3 months ago

Use the specfill argument to provide a list of the valid colors for categorical variables. The list consists of named character vectors of value = hexcolor.

For example, if you had the categorical variables "sex" and "maritalStatus", you could add this parameter to vtree:

specfill = list(sex = c("female="red","male"="blue"), maritalStatus = c("married"="orange",single="green"))

Note that currently, the maximum number of values (colors) for a given variable is 9. I just created an issue report on this and hope it will be changed in the next version.