我使用了格子包parallelplot方法来绘制数据并遇到生成图例的麻烦。我为绘图创建了一个自定义颜色矢量,但找不到传递它们的方法来覆盖图例中显示的默认颜色。虽然我已经没时间并且最终修正了Photoshop中的图例颜色,但我想学习格子中正确的方法。
以下是使用4列图例生成图表的代码:
parallelplot(acc, horizontal.axis=FALSE, col=acc_colors, lwd=1.5, cex=2.5,
ylab="Accuracy (Min = 50%, Max = 100%)",
xlab="Activity (overall = average across activities)",
main="Human Activity Recognition Accuracy",
scales=list(cex=1),
auto.key=list(text=c("Test Set", "Test Subject", "Training Set", "Training Subject"),
title=" ",
space="top", columns=4, points=FALSE)
)
如何传递自定义图例颜色?
答案 0 :(得分:7)
使用show.settings()和str(trellis.par.get())显示需要自定义的图形参数是superpose.line。使用par.settings传递自定义设置时,仍然使用auto.key提供自定义键颜色和线宽:
acc_par <- list(superpose.line = list(col = key_colors), lwd=1.5, lty=1.5)
parallelplot(acc, horizontal.axis=FALSE, col=acc_colors, lwd=1.5, cex=2.5,
ylab="Accuracy (Min = 50%, Max = 100%)",
xlab="Activity (overall = average across activities)",
main="Human Activity Recognition Accuracy",
scales=list(cex=1),
par.settings=acc_par,
auto.key=list(text=c("Test Set", "Test Subject", "Training Set", "Training Subject"),
title=" ", space="top", columns=4, lines=TRUE)
)
}
此article有助于找到此解决方案。