R-来自不同数据集但相同颜色传说的盒子图
我有两个表示相同的数据集,但一个来自模拟数据,另一个来自真实数据。我想将这两个与盒子图进行比较。到目前为止,我确实像您在图像中看到的那样绘制它们。问题是,我希望一个组中的每个盒子图都具有不同的颜色,但对于两个数据集都相同,因此,模拟数据的alpha = 0.2,只有5种不同的颜色。假设,要将真实的“ dt”'rfr'与模拟的“ dt”“ rfr”进行比较,我想拥有两个带有相同颜色的盒子图,但一个“ alphaed'。
此外,我不知道该如何在两列传奇中展示,一个用于真实标签,一个用于模拟标签(在开始的标签上带有's'的标签)。
我的绘图代码是以下
p <- ggplot()+geom_boxplot(data=simulation,aes(x=param,y=data, fill=algo), alpha=0.2)+
geom_boxplot(data=ADCF2param_shuffle,aes(x=param, y = data, fill=algo))+
geom_point(data =gt_vs_fitted,aes(param, y = data), color='red', size=4, shape=18)
p+scale_fill_brewer(palette="YlGnBu") + theme_classic() + labs(y="CCC", x= "Parameters")
在这里一些示例数据。对于每个“算法”,我都有每个“参数”的数据。以及模拟数据中相同的结构。
I have two datasets that represent the same, but one from simulated data and other from real data. I want to compare both with boxplots. So far, I did plot them as you can see in the image. The question is, I want each boxplot in a group to have a different color but being the same for both datasets, so it would be only 5 different colors where the simulated data have alpha=0.2. Let say, to compare real 'Dt' 'RFR' with simulated 'Dt' 'RFR' I'd like to have two boxplots with the same color but one "alphaed".
In addition, I don't know how can I show that in a two column legend, one for the real labels and one for the simulated labels (the ones with and 's' at the beggining).
My code for the plot is the following
p <- ggplot()+geom_boxplot(data=simulation,aes(x=param,y=data, fill=algo), alpha=0.2)+
geom_boxplot(data=ADCF2param_shuffle,aes(x=param, y = data, fill=algo))+
geom_point(data =gt_vs_fitted,aes(param, y = data), color='red', size=4, shape=18)
p+scale_fill_brewer(palette="YlGnBu") + theme_classic() + labs(y="CCC", x= "Parameters")
Here some sample data. For each 'algo' I have some data of every 'param'. And the same structure in the simulation data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
在2022-07-04创建的 reprex软件包 (v2.0.1)
Try this:
Created on 2022-07-04 by the reprex package (v2.0.1)