2014-10-31 34 views
0

嗨,我想在barchart的兩個面板中添加不同的文本。這兩個文本值表示barchart中0值的百分比。我一直在尋找不同的幫助網站,但還沒有找到答案。這裏是我的嘗試:向條形圖中的面板添加不同的文本

數據

dput(ztable) 
structure(list(Group.1 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 11L, 12L, 14L, 17L, 19L, 29L, 115L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 11L, 12L, 14L, 17L, 19L, 29L, 115L), .Label = c("0", 
"10", "20", "30", "40", "50", "60", "70", "80", "90", "100", 
"110", "120", "130", "140", "150", "160", "170", "180", "190", 
"200", "210", "220", "230", "240", "250", "260", "270", "280", 
"290", "300", "310", "320", "330", "340", "350", "360", "370", 
"380", "390", "400", "410", "420", "430", "440", "450", "460", 
"470", "480", "490", "500", "510", "520", "530", "540", "550", 
"560", "570", "580", "590", "600", "610", "620", "630", "640", 
"650", "660", "670", "680", "690", "700", "710", "720", "730", 
"740", "750", "760", "770", "780", "790", "800", "810", "820", 
"830", "840", "850", "860", "870", "880", "890", "900", "910", 
"920", "930", "940", "950", "960", "970", "980", "990", "1000", 
"1010", "1020", "1030", "1040", "1050", "1060", "1070", "1080", 
"1090", "1100", "1110", "1120", "1130", "1140"), class = "factor"), 
    Group.2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Fall", "Spring" 
    ), class = "factor"), x = c(677L, 344L, 18L, 6L, 5L, 4L, 
    0L, 2L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 82L, 186L, 15L, 6L, 
    8L, 1L, 3L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L)), .Names = c("Group.1", 
"Group.2", "x"), row.names = c(NA, -32L), class = "data.frame") 

條形圖代碼

​​

回答

0

你只需要在你的panel.text()功能的小錯誤。 x和y座標使其無法讀取文本。 barchart(這是panel.text函數中的第一個數字)中的x座標是指小節編號。你有1,把它放在中間。 y coordiante指的是y軸上的值。這是您的panel.text' function. It is currently 0, but 400 works better. So replace your panel.text`行的第二個數字與此:

panel.text(8,400,labels=mytext[panel.number()]) } 

,你會得到:

enter image description here

+0

非常感謝你。我不明白在panel.text中x和y是什麼意思。 – user41509 2014-11-03 16:15:51

相關問題