我期待从set1调色板中看到颜色名称.我需要在图表上使用数字4和5,即紫色和橙色.我不知道他们的代码.请指出我在哪里可以找到他们的名字或代码.非常感谢.
在set1我提的是在这里:
https://learnr.wordpress.com/2009/04/15/ggplot2-qualitative-colour-palettes/
非常感谢任何建议
Jas*_*ang 12
你可以找到代码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
Run Code Online (Sandbox Code Playgroud)
# Retrieve the color
colors <- ggplot_build(g)$data[[1]]$colour
# Double check
plot(df$x, df$y, col=colors, pch=20, cex=5)
Run Code Online (Sandbox Code Playgroud)
# color 4 and 5
colors[4:5]
[1] "#984EA3" "#FF7F00"
Run Code Online (Sandbox Code Playgroud)