Skip to content

How to create custom RColorBrewer palette? #36

@lejarx

Description

@lejarx

I want to change the color scale based on a hex code color I provide.

For example below the color_scale argument takes a value based on available color palette from RColorBrewer library

library(bupaR)
patients %>%
    process_map(type = frequency("relative_case", color_scale = "Purples"))

Is there any way that I can create a custom palette which is not part of the RColorBrewer palette (RColorBrewer::brewer.pal.info) so that it can be an input to the process_map color_scale argument?

For example, I want the color scale to be generated based on this hexcode #004b88.

If I simply replace the hexcode as below, I would get the following error which suggests that I'm only bounded by whatever color palettes provided by RColorBrewer which I think shouldn't be the case

> patients %>%
+     process_map(type = frequency("relative_case", color_scale = "#004b88"))
Error: `colorize_node_attrs()` REASON:
* The color palette is not an `RColorBrewer` or `viridis` palette`()` REASON:
* The color palette is not an `RColorBrewer` or `viridis` palette`()` REASON:
* The color palette is not an `RColorBrewer` or `viridis` palette

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions