【发布时间】:2015-06-09 16:02:42
【问题描述】:
我尝试使用 ggplot 库在 Python 中创建图表。
我的数据是这样的格式:
id total
1 3
1 4
1 7
2 3
2 2
2 5
我想创建一个条形图,其中每个 id 都有自己的条形图。 y 将是特定 id 的总列的平均值,并且还会为每个条添加带有最小值和最大值的错误区域。
我是 ggplot 的新手。我使用过散点图和折线图,但没有使用条形图。
我发现可以用
创建条形图gg = ggplot(mydata, aes(....)) + geom_bar()
但我不知道要在 aes 上添加什么。
【问题讨论】:
-
好的,在 R ggplot 中有一个
stat_summary。我在 Python 版本中没有看到这样的功能。我建议只修改数据并使用ggplot(mydaya, aes(x='factor(x)', y=y)) + geom_bar()。我不确定语法,附近没有 Python 版本。
标签: python ggplot2 python-ggplot