gpt4 book ai didi

从 geom_bar 图例 ggplot r 中删除点

转载 作者:行者123 更新时间:2023-12-04 11:09:28 27 4
gpt4 key购买 nike

这是我的数据。

Mod <- as.factor(c(rep("GLM",5),rep("MLP",5),rep("RF",5),rep("SVML",5),rep("SVMR",5)))
Manifold <- as.factor(rep(c("LLE","Iso","PCA","MDS","kPCA"),5))
ROC <- runif(25,0,1)
Sens <- runif(25,0,1)
Spec <- runif(25,0,1)
df <- data.frame("Mod"= Mod, "Manifold"= Manifold, "ROC" = ROC, "Sens" = sens, "Spec" = spec)

我正在制作这张图

resul3 <- ggplot(df, aes(x = Mod, y = ROC, fill= Manifold)) + 
geom_bar(stat = "identity", position = "dodge", color = "black") +
ylab("ROC & Specificity") +
xlab("Classifiers") +
theme_bw() +
ggtitle("Classifiers' ROC per Feature Extraction Plasma") +
geom_point(aes(y=Spec), color = "black", position=position_dodge(.9)) +
scale_fill_manual(name = "Feature \nExtraction", values = c("#FFEFCA",
"#EDA16A" ,"#C83741", "#6C283D", "#62BF94"))

first graph

我想要的是另一个标题为“特异性”和一个黑点的图例。我不希望该点位于 Manifolds 图例中。

Something like this but without the points inside the manifold squares

最佳答案

更改 geom_point 行,添加 scale_color_manual 并使用 @drmariod 的回答中看到的覆盖将导致此图:

ggplot(df, aes(x = Mod, y = ROC, fill= Manifold)) + 
geom_bar(stat = "identity", position = "dodge", color = "black") +
ylab("ROC & Specificity") +
xlab("Classifiers") +
theme_bw() +
ggtitle("Classifiers' ROC per Feature Extraction Plasma") +
geom_point(aes(y=Spec, color = "Specificity"), position=position_dodge(.9)) +
scale_fill_manual(name = "Feature \nExtraction", values = c("#FFEFCA",
"#EDA16A" ,"#C83741", "#6C283D", "#62BF94")) +
scale_color_manual(name = NULL, values = c("Specificity" = "black")) +
guides(fill = guide_legend(override.aes = list(shape = NA)))

enter image description here

关于从 geom_bar 图例 ggplot r 中删除点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48763802/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com