R Colors Brewer Get HEX [duplicate]
Asked Answered
P

2

5

I am wondering, how is it possible to get the HEX # for brewer color palettes?

https://learnr.wordpress.com/2009/04/15/ggplot2-qualitative-colour-palettes/

Partitive answered 5/4, 2020 at 21:34 Comment(0)
P
5
# Extract the hexadecimal color values for a particular palette from
# the RColorBrewer package, as used by ggplot's scales package. 

library("RColorBrewer")

brewer.pal(12, "Paired")

# [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C"
# [7] "#FDBF6F" "#FF7F00" "#CAB2D6" "#6A3D9A" "#FFFF99" "#B15928"

# to display that palette:
display.brewer.pal(12, "Paired")

SOURCE: https://gist.github.com/jtoll/4021792

Partitive answered 5/4, 2020 at 21:38 Comment(0)
E
14

Is this what you're looking for?

library(RColorBrewer)
brewer.pal(n=5,"Set1")
[1] "#E41A1C" "#377EB8" "#4DAF4A" "#984EA3" "#FF7F00"
Ephraimite answered 5/4, 2020 at 21:38 Comment(0)
P
5
# Extract the hexadecimal color values for a particular palette from
# the RColorBrewer package, as used by ggplot's scales package. 

library("RColorBrewer")

brewer.pal(12, "Paired")

# [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C"
# [7] "#FDBF6F" "#FF7F00" "#CAB2D6" "#6A3D9A" "#FFFF99" "#B15928"

# to display that palette:
display.brewer.pal(12, "Paired")

SOURCE: https://gist.github.com/jtoll/4021792

Partitive answered 5/4, 2020 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.