鱼C论坛

 找回密码
 立即注册
查看: 3422|回复: 8

[已解决]Pyecharts 遇上错误-求平均值、最大值、最小值

[复制链接]
发表于 2020-3-20 21:40:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. from pyecharts.charts import Bar
  2. g=["河东","河北","河西","南开","红桥","和平"]
  3. y=[15,12,4,6,2,6]
  4. bar=Bar( )
  5. bar.add_xaxis(g)
  6. bar.add_yaxis("COVID-19天津市内六区统计数字",y)
  7. bar.add_axis(mark_line=["average"],mark_point=["max","min"])
  8. bar.render("6_district.html")
复制代码
好似错在: 求平均值、最大值、最小值,怎么修改下呢?

最佳答案
2020-3-20 23:16:01
  1. from pyecharts.charts import Bar
  2. from pyecharts import options as opt


  3. g = ["河东", "河北", "河西", "南开", "红桥", "和平"]
  4. y = [15, 12, 4, 6, 2, 6]
  5. bar = Bar()
  6. bar.add_xaxis(g)

  7. bar.add_yaxis("COVID-19天津市内六区统计数字", y)

  8. bar.set_series_opts(markpoint_opts=opt.MarkPointOpts(data=[opt.MarkPointItem(type_="max", name="最大值"),
  9.                                                            opt.MarkPointItem(type_="min", name="最小值")]),
  10.                     markline_opts=opt.MarkLineOpts(data=[opt.MarkLineItem(type_="average", name="平均值")]))

  11. bar.render("6_district.html")
复制代码

标记点和标记线那里调的接口是错的
1.png
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-20 21:45:10 | 显示全部楼层
这是拼写错误吧。。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-20 21:48:45 | 显示全部楼层
qiuyouzhi 发表于 2020-3-20 21:45
这是拼写错误吧。。。

我拿不准,应该怎么写呢?我研究一天了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-20 21:55:43 | 显示全部楼层
dragov 发表于 2020-3-20 21:48
我拿不准,应该怎么写呢?我研究一天了

呃,那你都不看错误提示的么?
AttributeError:'Bar' objecthas no attribute 'add_axis'
意思就是Bar没有add_axis属性,所以你在第7行的时候调用bar.add_axis就出错了。你去检查一下Bar,应该是你写错 了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-20 22:15:09 | 显示全部楼层
sunrise085 发表于 2020-3-20 21:55
呃,那你都不看错误提示的么?
AttributeError:'Bar' objecthas no attribute 'add_axis'
意思就是Bar ...

就是第7行写错了!
怎么改呢?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-20 22:27:22 | 显示全部楼层
dragov 发表于 2020-3-20 22:15
就是第7行写错了!
怎么改呢?

不是和你说了么?
查看下Bar,肯定是你写错了Bar没有add_axis
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-20 23:16:01 | 显示全部楼层    本楼为最佳答案   
  1. from pyecharts.charts import Bar
  2. from pyecharts import options as opt


  3. g = ["河东", "河北", "河西", "南开", "红桥", "和平"]
  4. y = [15, 12, 4, 6, 2, 6]
  5. bar = Bar()
  6. bar.add_xaxis(g)

  7. bar.add_yaxis("COVID-19天津市内六区统计数字", y)

  8. bar.set_series_opts(markpoint_opts=opt.MarkPointOpts(data=[opt.MarkPointItem(type_="max", name="最大值"),
  9.                                                            opt.MarkPointItem(type_="min", name="最小值")]),
  10.                     markline_opts=opt.MarkLineOpts(data=[opt.MarkLineItem(type_="average", name="平均值")]))

  11. bar.render("6_district.html")
复制代码

标记点和标记线那里调的接口是错的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-21 07:12:03 | 显示全部楼层
fish_游鱼 发表于 2020-3-20 23:16
标记点和标记线那里调的接口是错的
谢谢您
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-21 10:13:38 | 显示全部楼层
写错了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-12 18:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表