2014-09-19 77 views
0

當前嘗試創建此chart圖表佈局和酒吧標籤

有一些困​​難,讓中箱號1

而且不知道如何在酒吧內標註的圖形,任何幫助,將不勝感激! 我到目前爲止的代碼是

Subject = 
    c("Humanities", "Social Sciences", "Science", "Economics", "Engineering", 
    "Construction", "Electrical Engineering", "Vehicles and Transport", 
    "Business Studies", "Industrial Engineering", "Agriculture", 
    "Nursing (Care)", "Catering", "Nursing") 
Female = 
    c(85, 71, 52, 56, 19, 1, 4, 4, 62, 3, 50, 87, 58, 92) 
Area = 
    c("Theory", "Theory", "Theory", "Theory", "Theory", "Vocational", 
    "Vocational", "Vocational", "Vocational", "Vocational", "Vocational", 
    "Vocational", "Vocational", "Vocational") 
Male = 100 - Female 

Data = data.frame (Subject = Subject, Area = Area, 
        Female = Female, Male = Male) 
orderFemale = order (Data$Female) 
Gender1991 = Data[orderFemale, ] 
head (Gender1991) 

##Create a plotting layout. Check with layout.show then remove 
layout (matrix (c (0, 0, 0, 0, 
       0, 5, 5, 0, 
       0, 4, 3, 0, 
       0, 2, 1, 0, 
       0, 0, 0, 0), 
      nc = 4, byrow = TRUE), 
    widths = c (lcm(1), 1, 1, lcm(1)), 
    heights = c (lcm(1), lcm(1), lcm (1), 
       1, lcm(1))) 
layout.show (5) 
par (mar = rep (0, 4)) 

xlim = c (0, 100) 
ylim = c (0, length (Gender1991$Female)) 
yt = 1:length (Gender1991$Female) 
yb = yt - 1 

##Female data plotting 
plot.new() 
plot.window (xlim = xlim, ylim = ylim, xaxs = "i", yaxs = "i") 
rect (0, yb, Gender1991$Female, yt) 
axis (1) 
axis (3) 
box() 

##Male data plotting 
plot.new() 
plot.window (xlim = rev(xlim), ylim = ylim, xaxs = "i", yaxs = "i") 
rect (0, yb, Gender1991$Male, yt) 
axis (1) 
axis (3) 
box() 

label.panel = 
    function (label, xadj = .5, yadj = .5, cex = 1, 
     font = 1, col = "black", angle = 0){ 
plot.new() 
plot.window (xlim = c (0, 1), ylim = c (0, 1), xaxs = "i", yaxs = "i") 
text (xadj, yadj, label, font = font, cex = cex, col = col, 
     adj = c (xadj, yadj), srt = angle) 
    } 

genderLabel = c ("Number of girls", "Number of boys") 
heading = "Intake by sex into three-year courses at upper secondary school 1991" 

label.panel (genderLabel[1], xadj = 1) 
label.panel (genderLabel[2], xadj = 0) 
label.panel (heading, font = 2) 

但這個代碼目前已經制造出圖佔據整個區域,並有一些其他格式問題。 會很感激一些建議,謝謝

回答

0

我不知道,希望能幫助大多數的這一點,但 我注意到,圖上的軸被標記在25,50,75和100

要調整你的匹配,這是你可以做什麼

##Female data plotting 
plot.new() 
plot.window (xlim = xlim, ylim = ylim, xaxs = "i", yaxs = "i") 
rect (0, yb, Gender1991$Female, yt) 
axis (1) 
axis (3) 
box() 

在各軸的()改變到 軸線(圖1,在=破折號) 凡破折號是一個矢量(0,25,50, 75,100)

希望這會有所幫助