通过将横坐标倾斜,可以增加横坐标的显示内容:
axislabel_opts={"rotate":50}
效果:
倾斜前
倾斜后
allDate=allDate.sort_values(by='Date') from pyecharts import options as opts from pyecharts.charts import Bar import os from pyecharts.options.global_options import ThemeType attrmax=allDate['Date'] v1=allDate['Confirmed'] bar=(Bar( init_opts=opts.InitOpts(bg_color='rgba(255,250,205,0.2)', width='800px', height='400px', page_title='疫情数据', theme=ThemeType.MACARONS ) ) .add_xaxis(attrmax.to_list()) .add_yaxis("人数",v1.to_list(),stack='stack1') .set_global_opts(title_opts=opts.TitleOpts(title="疫情情况"), xaxis_opts=opts.AxisOpts(name='日期',axislabel_opts={"rotate":50}), yaxis_opts=opts.AxisOpts(name='确诊人数:人')) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) ) bar.render_notebook()