【发布时间】:2020-10-30 19:00:24
【问题描述】:
我正在根据我模拟的数据创建下面的图表。数据由两组 A 和 B 组成,每组具有从不同分布中提取的不同值。当我使用下面的代码创建条形图时,每个模拟图的色标范围都会发生变化。例如,顶部图像的深红色映射为 90,而底部图像为 120。在所有图表的创建过程中,我需要将颜色映射到相同的值。
## GGPLOT: Ensemble Stripplts ##
for(i in 1:max(unique(saveDT$iter))){
#grab the data for this dataset
gg<-saveDT[which(saveDT$iter==i),]
gg$group<-factor(gg$group)
# set the limits of the palette so that zero is in the middle of the range.
# png(paste0("aggIndividGroupV1","-",sa,".png"), width = 400, height = 300)
# par(mar=c(1, 1, 1, 1))
print(ggplot(gg, aes(x=i, y=1,fill=value)) + facet_grid(. ~ group)+
theme(strip.background = element_rect(color="white", fill="white"))+
geom_vline(aes(xintercept = value, lwd=5, color=value))+
scale_colour_gradientn(colours=rev(brewer.pal(9,"RdBu"))))
}
Q1:如何修复色阶?
Q2:如何更改中点值以表示特定的固定中点?
Q3:为什么 ggplot() 使 RdBu brewer 调色板看起来与在 plot() 函数中使用 RdBu 时明显不同? (参见最后一张图片进行比较)。 Plot() 似乎使它们看起来更饱和,渐变更少。我尝试使用代码 scale_fill_divergentx() 但此类型和其他类型不适用于我的 ggplot() 函数。
【问题讨论】: