import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.globals import ThemeType from pyecharts.faker import Faker datex = [1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009] datey = [0.32,0.32,0.32,0.32,0.33,0.33,0.34,0.37,0.37,0.37,0.37,0.39,0.41,0.42,0.44] ( Line(init_opts=opts.InitOpts(theme=ThemeType.DARK)) .set_global_opts( title_opts=opts.TitleOpts(title= " 美国邮费阶梯图",subtitle="课本例1"), # toolbox_opts = opts.ToolboxOpts(is_show=True), # legend_opts = opts.LegendOpts(is_show=True), yaxis_opts=opts.AxisOpts( min_=3, max_=4.5, type_="value", axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), visualmap_opts = opts.VisualMapOpts(is_show=True) # "Price",datx, daty, is_tep = True,is_label_show = True,yaxis_min =0.3, # yaxis_max = 0.45 ) .add_xaxis(xaxis_data = datex) .add_yaxis( series_name = "Price", y_axis = list(datey), # y_axis = Faker.values(), # datey, is_step=True, symbol="emptyCircle", is_symbol_show=True, label_opts=opts.LabelOpts(is_show=True), # markline_opts=opts.MarkPointOpts( # data=[ # opts.MarkPointItem(type_="min",y=0.32), # opts.MarkPointItem(type_="max",y=0.44), # ] # ), # # 是否选中图例 # is_selected = True, # # 是否连接空数据,空数据使用 `None` 填充 # is_connect_nones = True, # linestyle_opts = opts.LineStyleOpts( # is_show=True, # opacity=1, # ) ) .set_colors(['RED','BLACK']) .render_notebook() ) # Line()
以上图为例
运行结果
错误原因:数据类型,(此处不涉及echarts 主题,Echart有自带的主题,但是pyecharts如果要使用其他主题的画,需要安装echarts-themes-pypkg包。它提供了 vintage, macarons, infographic, shine 和 roma等主题。使用命令
pip install echarts-themes-pypkg
)
datex 虽然为list 数据,但是此处需要的是str
快速直接、简单粗暴修改
同时 修改
你以为这就结束了?
?
?
?
?
?
???????
?
?
?
?
?
是的,就这么简单