3
我想访问默认线或从ggplot2填充颜色,我不知道如何做到这一点。具体来说,在下面的代码中,您将在注释中看到green4,blue4和red4。这些是我的近似值我认为ggplot2
正在使用。此外,如果此代码没有遵循最佳做法或可能受益于替代方法,请告知。使用ggplot2图形的默认填充颜色通过注释在R
library(ggplot2)
ggplot(data.frame(x = c(0, 1000)), aes(x)) +
stat_function(fun = dnorm, geom = "density", args = list(mean = 200, sd = 50),
aes(color="technology", fill="technology", alpha= 0.75)) +
stat_function(fun = dnorm, geom = "density", args = list(mean = 500, sd = 200),
aes(color="textiles", fill="textiles", alpha = 0.75)) +
stat_function(fun = dnorm, geom = "density", args = list(mean = 750, sd = 100),
aes(color="pharmaceuticals", fill="pharmaceuticals", alpha = 0.75)) +
labs(list(title="Fictious 'Density' Returns by Industry", x=NULL, y=NULL, color="Industry")) +
theme(legend.position="none") +
theme(axis.ticks = element_blank(), axis.text.y = element_blank()) +
annotate("text", label="technology", x=275, y=0.008, color="green4") +
annotate("text", label="textiles", x=500, y=0.0025, color="blue4") +
annotate("text", label="pharmaceuticals", x=835, y=0.0045, color="red4")
谢谢 - 我其实是有添加另一个'sapply(...,唯一的)',以避免抓住每一个的所有元素101列表标签。 – JasonAizkalns