我在ggplot中指定我的传说中的颜色有两个不同的问题.我试图制作一个简单的例子来说明我的问题:
df <- data.frame(x=rep(1:9, 10), y=as.vector(t(aaply(1:10, 1, .fun=function(x){x:(x+8)}))), method=factor(rep(1:9, each=10)), DE=factor(rep(1:9, each=10)))
ggplot(df, aes(x, y, color=method, group=DE, linetype=DE)) + geom_smooth(stat="identity")
Run Code Online (Sandbox Code Playgroud)
出于某种原因,标题DE下的图例中显示的线型都是蓝色.我希望他们是黑人,但我不知道他们为什么一开始就是蓝色,所以我不知道如何改变它们.
对于我的另一个问题,我试图使用点颜色和点形状来显示我的数据中的两个不同的区别.我想要传说这两个.这就是我所拥有的:
classifiers <- c("KNN", "RF", "NB", "LR", "Tree")
des <- c("Uniform", "Gaussian", "KDE")
withoutDE <- c(.735, .710, .706, .628, .614, .720, .713, .532, .523, .557, .677, .641, .398, .507, .538)
withDE <- c(.769, .762, .758, .702, .707, .752, .745, .655, .721, .733, .775, .772, .749, .756, .759)
df <- data.frame(WithoutDE=withoutDE, WithDE=withDE, DE=rep(des, each=5), Classifier=rep(classifiers, 3))
df <- cbind(df, Method=paste(df$DE, …Run Code Online (Sandbox Code Playgroud)