Cla*_*lay 11 python pandas python-ggplot
我正在使用yhat的ggplot库.我有以下pandas DataFrame:
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
Run Code Online (Sandbox Code Playgroud)
目前,我正在执行以下操作(在df函数的第一行的第一行中返回的是上面的DataFrame):
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)
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:

然而,每当我尝试geom_bar()而不是geom_point(),我最终只有100%的酒吧.我已经尝试过简单geom_bar()而且geom_bar(stat="percent observed"),但似乎都不起作用.这总是我得到的:

我要做的是模仿/重现以下内容:

任何想法如何使酒吧部分工作(或整个事情,为此)?
HYR*_*YRY 24
使用weight,这是一个例子:
from ggplot import *
import pandas as pd
df = pd.DataFrame({"x":[1,2,3,4], "y":[1,3,4,2]})
ggplot(aes(x="x", weight="y"), df) + geom_bar()
Run Code Online (Sandbox Code Playgroud)
输出看起来像:

| 归档时间: |
|
| 查看次数: |
10510 次 |
| 最近记录: |