首先,我了解了position =“fill”功能,我甚至成功地绘制了原始数据。 使用此代码
g <- ggplot(results, aes(Class))
g + geom_bar(aes(fill = Rating), position = "fill")
看起来像this
然而,当我想绘制建模数据时,我无法让它合作。
以下是数据的示例
class <- (c(rep(1,4),rep(2,4), rep(3,4)))
rating <- rep(c(1,2,3,4),3)
proportion <- c(0.3304, 0.4241, 0.1305, 0.1150,
0.4119, 0.4016, 0.1026, 0.0839,
0.2831, 0.4279, 0.1493, 0.1397)
df <- data.frame(class,proportion,rating)
df$class <- as.factor(df$class) df$rating <- as.factor(df$rating)
g <- ggplot(df, aes(class))
g + geom_bar(aes(fill = proportion),
position = "fill")
但这给了我this kind of image。我现在已经搞砸了一段时间,但还没有找到解决方案。
你们中有些人知道该怎么做吗?非常感谢帮助。
答案 0 :(得分:1)
您需要将dim xml,node,nodes,Root,strNames
Set xml = CreateObject("MSXML2.DOMDocument.6.0")
xml.Async = False
xml.Load "C:\Users\pankaj.jaju\Desktop\test.xml"
xml.setProperty "SelectionLanguage","XPath"
strNames = ""
For Each Node in xml.selectnodes("//DS001History/EventID[number(text())=1]")
strNames = strNames & Node.tagname
Next
msgbox strNames
明确映射到y轴,并根据评级进行填充。正如乔兰所指出的,你可以使用proportion
或过时的geom_col
。
geom_bar(stat = "identity")