python可视化大屏-疫情监控图(3)条形图和面积图
2021/11/9 1:10:18
本文主要是介绍python可视化大屏-疫情监控图(3)条形图和面积图,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
最终结果
数据准备
条形图
data_votes = pd.read_excel(r'地域划分副本.xlsx') # data_votes # 数据排序,倒过来画图好看点 data_votes = data_votes.sort_values(by='出现次数',ascending=True) # data_votes # 数据结构重组 data_votes_x = data_votes['职称'].tolist() data_votes_y = data_votes['出现次数'].tolist() # 画条形图 from pyecharts import options as opts from pyecharts.charts import Bar bar2 = ( Bar(init_opts=opts.InitOpts(width='400px',height='300px',theme=ThemeType.DARK)) .add_xaxis(data_votes_x) .add_yaxis("", data_votes_y ) .reversal_axis() # 旋转柱形图方向 .set_series_opts(label_opts=opts.LabelOpts(position="right")) # 设置数字标签位置 .set_global_opts(title_opts=opts.TitleOpts(title="《在一起》关键人物出现次数"), visualmap_opts=opts.VisualMapOpts( max_= max(data_votes_y), min_= min(data_votes_y), range_color = ['#ffe100','#e82727'], pos_right='5%', pos_top='49%', dimension = 0, # 柱形图需要加 ), ) ) bar2.render_notebook()
结果
面积图
import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.globals import ThemeType data = pd.read_excel(r'疫情华北华东西北新增趋势 - 副本.xlsx') x1 = data['日期'].agg(lambda x:str(x.day)).tolist() y_data1 = data['北京'] y_data2 = data['甘肃'] y_data1 c2 = ( Line(init_opts=opts.InitOpts(width='500px',height='400px',theme=ThemeType.DARK)) .add_xaxis(x1) .add_yaxis( series_name="北京", stack="新增量", y_axis=y_data1, areastyle_opts=opts.AreaStyleOpts(opacity=0.5), label_opts=opts.LabelOpts(is_show=False), color='#FF8C69', is_smooth=True, ) .add_yaxis( series_name="甘肃", stack="新增量", y_axis=y_data2, areastyle_opts=opts.AreaStyleOpts(opacity=10), label_opts=opts.LabelOpts(is_show=False), color='#CD5C5C', is_smooth=True ) .set_global_opts( title_opts=opts.TitleOpts( title="北京甘肃新增区域图"), tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"), yaxis_opts=opts.AxisOpts( type_="value", axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), xaxis_opts=opts.AxisOpts(type_="category",boundary_gap=False), ) ) c2.render_notebook()
结果
这篇关于python可视化大屏-疫情监控图(3)条形图和面积图的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-24Python编程基础详解
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程