pyecharts v1 version of the study notes histogram

Histogram

Basic Presentation example bar

 

from pyecharts Import Options AS the opts
 from pyecharts.charts Import Bar 
c = ( 
Bar (). add_xaxis ([ " shirt " , " sweater " , " tie " , " pants " , " coat " , " high heels " , " socks " ] ) 
    .add_yaxis ( ' merchant A ' , [114, 55, 27, 101, 125, 27, 105 ]) 
    .add_yaxis ( 'Merchant B' , [57 is, 134, 137, 129, 145, 60, 49 ]) 
    .set_global_opts (title_opts = opts.TitleOpts (title = ' Bar- Basic Display ' , SUBTITLE = ' I subtitle ' )) 




) 
c.render_notebook ( )

 

 

 Default cancel a series

The default does not display the merchandise B

from pyecharts Import Options AS the opts
 from pyecharts.charts Import Bar 
c = ( 
Bar (). add_xaxis ([ " shirt " , " sweater " , " tie " , " pants " , " coat " , " high heels " , " socks " ] ) 
    .add_yaxis ( ' merchant A ' , [114, 55, 27, 101, 125, 27, 105 ]) 
    .add_yaxis ( 'Merchant B' , [57 is, 134, 137, 129, 145, 60, 49], is_selected = False) 
    .set_global_opts (title_opts = opts.TitleOpts (title = ' Bar- Basic Display ' , SUBTITLE = ' I subtitle ' )) 




) 
c.render_notebook ()

 

 

 

Display the toolbox

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
    add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
     .set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-显示 ToolBox"),
            toolbox_opts=opts.ToolboxOpts(),
            legend_opts=opts.LegendOpts(is_show=False)
        )


)
c.render_notebook()

 

 

bar Y轴formatter (y轴带坐标的)

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
    add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
     .set_global_opts(
           title_opts=opts.TitleOpts(title="Bar-Y 轴 formatter"),
            yaxis_opts=opts.AxisOpts(
                axislabel_opts=opts.LabelOpts(formatter="{value} /月")
            ),
        )


)
c.render_notebook()

 

 

 

Bar 指定类型  最大值,最小值,平均值显示

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
    add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
     .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkPoint(指定类型)"),
                      yaxis_opts=opts.AxisOpts(
                axislabel_opts=opts.LabelOpts(formatter="{value} /月")
            ),)
        .set_series_opts(
            label_opts=opts.LabelOpts(is_show=False),
            markpoint_opts=opts.MarkPointOpts(
                data=[
                    opts.MarkPointItem(type_="max", name="最大值"),
                    opts.MarkPointItem(type_="min", name="最小值"),
                    opts.MarkPointItem(type_="average", name="平均值"),
                ]
            ),
        )

)
c.render_notebook()

 

 

 

bar  -markline 指定类型(划横线那种)

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
     add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
    .set_global_opts(title_opts=opts.TitleOpts(title='Bar-MARKline显示数据'))
    .set_series_opts(
    label_opts=opts.LabelOpts(is_show=False),
        markline_opts=opts.MarkLineOpts(
                data=[
                    opts.MarkLineItem(type_="min", name="最小值"),
                    opts.MarkLineItem(type_="max", name="最大值"),
                    opts.MarkLineItem(type_="average", name="平均值"),
                ]
            ),
    
    
    
    
    )





)
c.render_notebook()

 

 

 

Bar 可以滑动的直方图 控制

from pyecharts.charts import Bar
c =(
Bar().add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"]).
     add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
   
.set_global_opts(
            title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-垂直)"),
            datazoom_opts=opts.DataZoomOpts(orient="vertical"),
        )




)
c.render_notebook()

 

Guess you like

Origin www.cnblogs.com/baili-luoyun/p/11058626.html