0
這是從我的CSV文件中的數據:情節線組點
Tx, Varx, Scale, Val1, Val2
A, VAR1, 5, 516, 2
A, VAR1, 10, 447.4, 5
A, VAR1, 15, 294, 8
A, VAR1, 20, 217.2, 12
A, VAR2, 5, 675.4, 4
A, VAR2, 10, 423.2, 9
A, VAR2, 15, 276, 12
A, VAR2, 20, 200, 15
B, VAR1, 5, 624, 6
B, VAR1, 10, 465.2, 13
B, VAR1, 15, 315.2, 16
B, VAR1, 20, 234.8, 18
B, VAR2, 5, 518.8, 8
B, VAR2, 10, 443, 17
B, VAR2, 15, 278.4, 20
B, VAR2, 20, 217.8, 24
我想繪製線(不只是分)VARx前提和Tx值之間distingish。我想使用此代碼繪製:
data_table = read.csv("PATH/file.csv",check.names=FALSE,header=T,sep=",")
data_table$NScale <- as.numeric(as.character((data_table$Scale)))
ggplot(data_table, aes(x=NScale, y=Val2, colour=Tx, shape=Varx, linetype=Varx, group=Tx)) + geom_point()
當我嘗試繪圖加盟藍triangules,紅triangules,紅色圓圈,藍色圓圈,用geom_line(),geom_path線()顯示錯誤消息:
Error: geom_path: If you are using dotted or dashed lines, colour, size and linetype must be constant over the line
如何通過形狀和顏色創建線條組?我嘗試了幾種方法,但仍然沒有得到它。問題是什麼?
非常感謝。你的回答非常有幫助。其實我使用'geom_line(aes(x = NScale,y = Val2,color = Tx,shape = Varx,linetype = Varx))' –
只是一個FYI,'geom_line'不理解'shape'唯美它實際上並沒有做任何事情:P – chappers
對! 'geom_line(aes(x = NScale,y = Val2,color = Tx,linetype = Varx))'謝謝! –