use*_*148 5 r colors histogram fill ggplot2
我在一个窗口中有两个直方图(使用facet),我想控制轮廓和填充的颜色.我已经尝试查找颜色scales,aes()+ color,+ fill,包括颜色和填充qplot,所有这些都会产生预期的情节!
我的代码可以在下面找到.(注意:mussel2有两个浓度列(数字列表)和水体(列出或参考).如有必要,我可以提供数据.
我知道这是一个基本问题,所以我很感激你的时间.
qplot(data=mussel2,
x = Concentration,
xlim = x_lim,
ylim = y_lim,
xlab = expression(paste("Concentrations of DDE (", mu, "g/g)")),
ylab = "Frequency",
binwidth = 1.5)+
theme(legend.position="none")+
facet_grid(Waterbody~.)
Run Code Online (Sandbox Code Playgroud)
如果要保留qplot格式,请尝试以下操作:
library(ggplot2)
qplot(diamonds$carat,
xlab="Carat",
geom="histogram",
ylab="Count",
binwidth=0.25,
fill=I("grey"),
col=I("black"))
Run Code Online (Sandbox Code Playgroud)
ggplot如果您想调整一些东西,请使用。我遗漏了一些选项,但您也许可以弄清楚如何将它们放入。
ggplot(data = mussel2, aes(x = Concentration)) +
geom_bar(binwidth = 1.5, fill = "firebrick4", color = "dodgerblue2") +
scale_x_continuous(limits = x_lim) +
labs(y = "Frequency") +
facet_wrap(~ Waterbody)
Run Code Online (Sandbox Code Playgroud)