I am looking to see the color name from set1
palette. I need to use number 4 and 5 on my graph, that are the violet and orange one. I don't know their code. Please point me to where I could find their name or code. Thanks a lot.
The set1
I am mentioning is here:
https://learnr.wordpress.com/2009/04/15/ggplot2-qualitative-colour-palettes/
Thanks so much for any suggestion
A color can be specified either by name (e.g.: “red”) or by hexadecimal code (e.g. : “#FF1234”).
In R, colors can be specified either by name (e.g col = “red”) or as a hexadecimal RGB triplet (such as col = “#FFCC00”). You can also use other color systems such as ones taken from the RColorBrewer package.
More specifically, ggpubfigs contains six color palettes that are colorblind friendly and aim to increase the accessibility of scientific figures and eight themes that modify 21 parameters of a default ggplot2 figure.
You can find out the code by ggplot_build
.
# fake data
df <- data.frame(x=1:8, y=1, col=letters[1:8])
# Construct the plot
g <- ggplot(df, aes(x=x, y=y, color=col)) + geom_point(size=5) +
scale_color_brewer(palette="Set1")
g
# Retrieve the color
colors <- ggplot_build(g)$data[[1]]$colour
# Double check
plot(df$x, df$y, col=colors, pch=20, cex=5)
# color 4 and 5
colors[4:5]
[1] "#984EA3" "#FF7F00"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With