我想在成对图中更改直方图条形的颜色,从而为每个变量设置不同的颜色。看来我可以通过将 'fill =' 选项更改为新颜色来更改所有对角线直方图的颜色,但是当我尝试替换四种颜色的列表时,我收到错误报告:
“r:美学必须是长度1或与数据相同(15):填充”
因此,颜色似乎以某种方式与为直方图指定的箱数而不是每个直方图的填充颜色相关联?
为对角线上的每个直方图实现不同颜色的最佳方法是什么?
下面的示例代码:
require(GGally)
# function for scatter plots with smoothed trend line
lower_plots <- function(data, mapping, ...) {
ggplot(data = data, mapping = mapping) +
geom_point(color = "black", shape = 1, size = 1, alpha = 1) +
geom_smooth(method = "gam",...)
}
# colour palette for histograms - subsitue for fill = ?
clrs <- c("red","green","blue","orange")
# pairs plot
ggpairs(iris,1:4,
diag = list(continuous = wrap("barDiag", bins = 15, fill = "blue")),
lower = list(continuous = wrap(lower_plots, color="red", se=F))) +
theme_light(base_size = 12) +
theme_light(base_size = 12) +
scale_fill_manual(values = ZNS[order(ZNS$Zone), 4]) +
theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank()) +
theme(plot.margin = unit(c(2.5,2.5,2.5,3.5), "lines")
)