pyecharts v1 版本 學習筆記 柱狀圖


柱狀圖

bar 基本演示例子

 

from pyecharts import options as opts
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-基本展示',subtitle='我是副標題'))




)
c.render_notebook()

 

 

 默認取消某series

默認不顯示B的商品

from pyecharts import options as opts
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],is_selected=False)
    .set_global_opts(title_opts=opts.TitleOpts(title='Bar-基本展示',subtitle='我是副標題'))




)
c.render_notebook()

 

 

 

顯示工具箱

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()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM