使用qplot更改直方图的轮廓和填充颜色

时间:2013-09-18 20:56:19

标签: r colors ggplot2 histogram fill

我在一个窗口中有两个直方图(使用小平面),我想控制轮廓和填充的颜色。我尝试查找颜色scalesaes(),+ 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~.)

2 个答案:

答案 0 :(得分:8)

如果您想保留qplot格式,请尝试以下操作:

library(ggplot2)

qplot(diamonds$carat, 
      xlab="Carat", 
      geom="histogram", 
      ylab="Count", 
      binwidth=0.25, 
      fill=I("grey"), 
      col=I("black"))

enter image description here

答案 1 :(得分:3)

如果要调整内容,请使用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)
相关问题