r
  • plot
  • 2017-03-08 66 views -1 likes 
    -1

    我正在繪製K-S測試結果。基本上是重要的和不重要的變量。我需要以可見的方式繪製圖例和軸值。如果您可以看到下圖,則Y軸值不可見。此外,圖例顯示一條虛線。我需要一個堅實的正方形或圓形的傳奇。條形圖:傳奇與軸線問題

    barplot(matrix, main="KS-Significance Test", 
         xlab="Proportion b/w InSig vs Sig", 
         ylab = 'Combinations', 
         yaxt="n",ylim=c(0,5), 
         cex.axis=0.8,cex.lab = 0.8,font = 2, horiz=TRUE, 
         col=c("darkgreen","darkred")) 
    legend('topright',legend= c("Insignificant","Significant"), 
         col= c("darkgreen","darkred"), lty = c(11,11),cex=0.8)) 
    

    請在下面找到矩陣數據。

    structure(c(" 78", " 75", " 49", "107", "134", "112", " 37", 
    " 41", " 32", " 47"), .Dim = c(2L, 5L), .Dimnames = list(c("Insignificant", 
    "Significant"), structure(c("2014-2015", "2014-2016", 
    "2015-2016", "2015-2017", "2016-2017"), .Names = c("1", "2", "3", "4", 
    "5")))) 
    

    以上格式是dput(矩陣)。如果需要矩陣視圖,請參閱此圖像 input data matrix image 還附加我的barplot圖像。
    Bar plot

    +0

    對不起,我收到的傳奇線。但我需要它更暗或更寬的線條,這實際上是可見的。 – Datascientist

    +3

    *「圖例和... x軸值正確」*。你能解釋一下你的意思嗎?我們無法讀懂你的想法,而「恰當地」對許多人來說可能意味着很多事情。 – r2evans

    +0

    @ r2evans:嗨謝謝你回來。同意你的觀點。如果您可以看到上面的條形圖,我的y軸標籤不可見。另外,由於我在這裏有5個堆疊酒吧,我的標籤不可見。我想以適當的可讀方式顯示它。其次,我的傳奇以虛線出現。我需要一個堅實的平方或圓圈顏色,這應該是可見的。我想,這解釋了我的觀點。 – Datascientist

    回答

    1

    謝謝大家。我找到了答案。傳奇問題也解決了。 這裏是代碼。

    barplot(matrix, main="KS-Significance Test", 
         xlab="Proportion b/w InSig vs Sig", 
         ylab = 'Combinations', 
         ylim=c(0,270), 
         cex.axis=0.8,cex.lab = 0.8,font = 4, 
         names.arg = c("Cohort 2014-2015", "Cohort 2014-2016", "Cohort 2015-2016","Cohort 2015-2017","Cohort 2016-2017"), 
         #horiz=TRUE, 
         col=c("darkgreen","darkred"), 
         legend = c("Insignificant","Significant")) 
    

    這完全符合我的情節。

    1

    使用fill代替col,並且不指定線型lty如果你不想線,但盒子的形狀 - 滿足您barplots :)

    legend('topright',legend= c("Insignificant","Significant"), 
        fill = c("darkgreen","darkred"), cex=0.8) 
    

    ,否則即寬行中,指定線寬lwd,這裏我使用實線lty=1lwd=10來獲得更黑和更寬的線條。

    legend('topright',legend= c("Insignificant","Significant"), 
        col = c("darkgreen","darkred"), lty = 1, lwd = 10, cex = 0.8) 
    
    +0

    謝謝R.S.您還可以幫助我使用Axis標籤的可見性 – Datascientist

    +0

    @PraveenKumarB對於我來說能夠幫助您使用軸標籤,您需要提供用於生成繪圖的數據。在你的原始問題下看到我的評論。有幾個原因爲什麼你的y軸沒有顯示,但我不能看出你正在繪製矩陣。 – Djork

    +0

    請參閱上面的問題。我已經添加了一個矩陣。 – Datascientist

    相關問題