目前正在尝试创建此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 :(得分: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,at = Dash) 短划线是(0,25,50,75,100)
的向量希望这有帮助