我在用yhat的ggplot library。我有以下熊猫数据框:
degree observed percent observed expected percent expected
0 0 0 0.0 0 0.044551
1 1 1 0.1 1 0.138604
2 2 3 0.3 2 0.215607
3 3 4 0.4 2 0.223592
4 4 1 0.1 2 0.173905
5 5 1 0.1 1 0.108208
目前,我正在执行以下操作(其中函数第一行第一行返回的df
是上面的数据帧):
def chartObservedExpected(graph):
df = observedExpected(graph)
return ggplot(aes(x='degree', y='percent observed'), data=df) + \
geom_point() + \
ylim(-0.015,1.015) + \
xlim(-0.05,max(df['degree']) + 0.25) + \
labs("Degree","Proportion of Total") + \
ggtitle("Observed Node Degree Distribution")
chartObservedExpected(G)
这就是我得到的:
然而,每当我尝试geom_bar()
而不是geom_point()
时,我最终只得到100%的条。我试过简单的geom_bar()
,也试过geom_bar(stat="percent observed")
,但都不管用。这就是我得到的:
我要做的是模仿/再现以下内容:
你知道怎么让酒吧部分运作吗?
使用
weight
,下面是一个示例:输出如下:
相关问题 更多 >
编程相关推荐