#coding:utf-8 import numpy as np import pandas as pd from pyecharts.charts import Geo value = [20,30,40,60,70,80,90,100,10] attr = ['荆州','长沙','渭南','临汾','十堰','唐山','郴州','铜陵','呼和浩特'] geo = Geo("全国各地销售量图",width=1200,height=600) geo.add("各网点销售量",attr,value,type="effectScatter",border_color="#ffffff",symbol_size=20,\ is_label_show=True,label_text_color="#00FF00",label_pos="inside",symbol="circle",\ symbol_color="FF0000",geo_normal_color="#006edd",geo_emphasis_color="#0000ff") geo.show_config() geo.render("geo.html")修改代码,解决 init() got an unexpected keyword argument 'width'这个问题
时间: 2023-11-12 09:06:08 浏览: 168
#_--_coding_UTF-8_--_import_sys,os,dlib,glob,nu_PythonFace.zip
这个问题可能是因为 pyecharts 版本过低导致的,可以尝试升级 pyecharts 到最新版本,或者修改代码如下,使用 `set_global_opts` 方法设置地图的宽度和高度:
```python
#coding:utf-8
import numpy as np
import pandas as pd
from pyecharts.charts import Geo
from pyecharts import options as opts
value = [20,30,40,60,70,80,90,100,10]
attr = ['荆州','长沙','渭南','临汾','十堰','唐山','郴州','铜陵','呼和浩特']
geo = Geo()
geo.add(
"各网点销售量",
attr,
value,
type="effectScatter",
border_color="#ffffff",
symbol_size=20,
is_label_show=True,
label_text_color="#00FF00",
label_pos="inside",
symbol="circle",
symbol_color="FF0000",
geo_normal_color="#006edd",
geo_emphasis_color="#0000ff"
)
geo.set_global_opts(
title_opts=opts.TitleOpts(title="全国各地销售量图"),
geo_opts=opts.GeoOpts(width="1200px", height="600px")
)
geo.show_config()
geo.render("geo.html")
```
这样就可以通过 `set_global_opts` 方法设置地图的宽度和高度,避免了 `init() got an unexpected keyword argument 'width'` 的问题。
阅读全文