2016-10-21 44 views
1

下面的Hello問題是使用點陣創建的情節。我正在使用lty = c(1,2),所以行是黑色的,但有兩種類型。然而在關鍵字中,線條顏色爲藍色&粉紅色?我不知道如何解決這個問題。謝謝!格點鍵與劇情中的美學不對應

column1 <- c(89.66, 89.66, 93.10, 96.55, 86.21, 89.66, 86.21, 79.31, 79.31, 79.31, 89.66, 82.76, 100, 93.33, 90, 93.33, 96.67, 96.67, 93.33, 93.33, 90, 93.33, 93.33, 93.33) 
column2 <- rep(c("SF36", "SF12"), c(12, 12)) 
column3 <- rep(c("1/12", "2/12", "3/12", "4/12", "5/12", "6/12", "7/12", "8/12", "9/12", "10/12", "11/12", "12/12"), 2) 
column3 <- factor(column3, levels=c("1/12", "2/12", "3/12", "4/12", "5/12", "6/12", "7/12", "8/12", "9/12", "10/12", "11/12", "12/12")) 
data2 <- data.frame(column1, column2, column3) 
xyplot(column1~column3, data=data2, groups=column2, lwd=2, col=c("black", "black"), lty=c(1, 2), pch=2, type="o", ylab=list(label="% of People who Answered", cex=2), scales=list(x=list(cex=2, rot=90), y=list(cex=2)), xlab=list(label="Proportion of Survey Progressed Through", cex=2), auto.key=list(space="top", columns=2, title="Group", cex.title=2, lines=TRUE, points=FALSE, cex=2)) 

回答

2

嘗試通過par.settings參數設置情節參數:

xyplot(column1~column3, data=data2, groups=column2, 
    par.settings = list(superpose.line = list(col = "black", 
               lty = c(1, 2), 
               lwd = 2), 
         superpose.symbol = list(pch = 2, col = "black")), 
    type="o", 
    ylab=list(label="% of People who Answered", cex=2), 
    scales=list(x=list(cex=2, rot=90), y=list(cex=2)), 
    xlab=list(label="Proportion of Survey Progressed Through", cex=2), 
    auto.key=list(space="top", columns=2, title="Group", cex.title=2, 
        lines=TRUE, points=FALSE, cex=2)) 

輸出: enter image description here