2014-09-19 6 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

에 표시되는 것으로 나타났습니다 당신이 당신이 대시의 벡터이다 (= 대쉬에서, 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() 

을 할 수있는 것입니다 일치하도록 조정하려면 (0, 25, 50, 75, 100)

희망이 있습니다.