【发布时间】:2021-12-28 10:05:30
【问题描述】:
我创建了一个冲积地块(下图)并且想交换颜色,所以未解决的是红色和已解决的绿色,但无法做到这一点。已经尝试过更改数据框,它没有任何区别。
我使用了脚本:
ggplot(data = D180_PROPOSAL1,
aes(axis1 = Data, axis2 = Issue,
y = Frequency)) +
scale_x_discrete(limits = c("Data", "Issue"), expand = c(.05, .1)) +
xlab("Assesment at Day 180") +
geom_alluvium(aes(fill = Unresolved)) +
geom_stratum() +
geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
theme_minimal() +
ggtitle("Uncertainties in the evaluation of bevacizumab biosimilars",
"stratified by type of data and type of issue")
Here is the picture of the plot
我还将数据集包含在链接中Dataset
【问题讨论】:
-
一种方法是使用
scale_fill_manual()函数,该函数允许您使用values参数定义冲积层的颜色。你可以写scale_fill_manual(values = c("Solved" = "#7CAE00", "Unresolved" = "#F8766D")),其中"#7CAE00"是默认的“绿色”,而“#F8766D”是默认的“红色”。 -
非常感谢!我试过了,但它不起作用..可能是因为我必须放入脚本的特定部分?
-
scale_fill_manual()是一个 ggplot 层。因此,您可以在构建包含建议解决方案的图形(从 ggplot 开始)的代码夹中添加一行。 -
为了帮助我们,我们需要能够复制您的代码。为此,我们需要“D180_PROPOSAL1”数据。
-
嗨!谢谢!我将数据集包含在上面的超链接中