def calendar_plot(df): """[summary] Parameters ---------- df : [type] [description] """ #begin = datetime.date(2020, 2, 9) #end = datetime.date(2020,11,11) begin = df.Fecha.min() end = df.Fecha.max() c = ( Calendar(init_opts=opts.InitOpts(width="1000px", height="300px")) .add( series_name="", yaxis_data=[[str(x),y] for x,y in zip(df.Fecha, df['Nuevos casos'])], calendar_opts=opts.CalendarOpts( pos_top="120", pos_left="30", pos_right="30", range_="2020", yearlabel_opts=opts.CalendarYearLabelOpts(is_show=False), ), ) .set_global_opts( title_opts=opts.TitleOpts(pos_top="20", pos_left="center", title="2020: Evolución del Covid19 en Andalucía"), visualmap_opts=opts.VisualMapOpts( max_=df['Nuevos casos'].max(), min_=0, orient="horizontal", is_piecewise=False ), ) ) st_pyecharts(c)
def calendar_in_Chinese(): calendar = Calendar( init_opts=opts.InitOpts(theme='light', width='1000px', height='600px')) calendar.add( '确证人数', yaxis_data=data, label_opts=opts.LabelOpts(is_show=True), calendar_opts=opts.CalendarOpts( # 日期范围 range_=['2020-01-21', '2020-04-30'], # 日历单元格尺寸 cell_size=50, # 年月日标签样式设置 # 星期和月份设置为中文显示,默认是英文 yearlabel_opts=opts.CalendarYearLabelOpts(margin=50), daylabel_opts=opts.CalendarDayLabelOpts(name_map='cn'), monthlabel_opts=opts.CalendarMonthLabelOpts(name_map='cn'))) # 设置视觉组件 calendar.set_global_opts(visualmap_opts=opts.VisualMapOpts( max_=1000000, is_piecewise=True, pieces=[{ "min": 1000000 }, { "min": 10000, "max": 1000000 }, { "min": 100, "max": 10000 }, { "max": 100 }], range_color=["#CCD3D9", "#E6B6C2", "#D4587A", "#DC364C"])) return calendar
def calendar_custom_cell(): calendar = Calendar( init_opts=opts.InitOpts(theme='light', width='1000px', height='600px')) calendar.add( '确证人数', yaxis_data=data, label_opts=opts.LabelOpts(is_show=True), calendar_opts=opts.CalendarOpts( # 日历位置 pos_top='10%', pos_left='10%', # 日期范围 range_=['2020-01-21', '2020-04-30'], # 日历单元格尺寸 cell_size=50, # 年月日标签样式设置 yearlabel_opts=opts.CalendarYearLabelOpts( margin=40, label_font_size=20, label_color='rgba(130,134,112,0.8)'), daylabel_opts=opts.CalendarDayLabelOpts(label_color='#778633', label_font_weight='bold'), monthlabel_opts=opts.CalendarMonthLabelOpts( label_color='#778633', label_font_weight='bold'))) # 设置视觉组件 calendar.set_global_opts(visualmap_opts=opts.VisualMapOpts( max_=1000000, is_piecewise=True, pieces=[{ "min": 1000000 }, { "min": 10000, "max": 1000000 }, { "min": 100, "max": 10000 }, { "max": 100 }], range_color=["#CCD3D9", "#E6B6C2", "#D4587A", "#DC364C"])) return calendar
time_list = date.split('-') time = datetime.date(int(time_list[0]), int(time_list[1]), int(time_list[2])) list1.append([str(time), pm]) calendar = Calendar() calendar.add( '', list1, calendar_opts=opts.CalendarOpts( pos_top="120", pos_left="30", pos_right="30", range_="2017", yearlabel_opts=opts.CalendarYearLabelOpts(is_show=False), ), ) calendar.set_global_opts( title_opts=opts.TitleOpts(pos_top="30", pos_left="center", title="2017年印度德里空气质量情况"), visualmap_opts=opts.VisualMapOpts(max_=300, min_=0, orient="horizontal", is_piecewise=False), ) calendar.render('heatmap.html')
import random import datetime from pyecharts import options as opts from pyecharts.charts import Calendar begin = datetime.date(2017, 1, 1) end = datetime.date(2017, 12, 31) data = [[str(begin + datetime.timedelta(days=i)), random.randint(1000, 25000)] for i in range((end - begin).days + 1)] c = (Calendar(init_opts=opts.InitOpts(width="1000px", height="500px")).add( series_name="", yaxis_data=data, calendar_opts=opts.CalendarOpts( pos_top="120", pos_left="30", pos_right="30", range_="2017", yearlabel_opts=opts.CalendarYearLabelOpts( is_show=False))).set_global_opts( title_opts=opts.TitleOpts(pos_top="30", pos_left="center", title="2017年步数情况"), visualmap_opts=opts.VisualMapOpts( max_=20000, min_=500, orient="horizontal", is_piecewise=False)).render("Calendar_heatmap.html"))
from pyecharts.charts import Calendar begin = datetime.date(2018, 1, 1) end = datetime.date(2019, 12, 31) data = [[str(begin + datetime.timedelta(days=i)), random.randint(1000, 25000)] for i in range((end - begin).days + 1)] print(data) c = (Calendar(init_opts=opts.InitOpts(width="1000px", height="500px")).add( series_name="", yaxis_data=data, calendar_opts=opts.CalendarOpts( pos_top="120", pos_left="30", pos_right="30", range_=["2018-01-01", "2019-12-31"], yearlabel_opts=opts.CalendarYearLabelOpts(is_show=True, margin=20), daylabel_opts=opts.CalendarDayLabelOpts(name_map="cn"), monthlabel_opts=opts.CalendarMonthLabelOpts(name_map="cn"), ), ).set_global_opts( title_opts=opts.TitleOpts(pos_top="30", pos_left="center", title="2019年步数情况"), visualmap_opts=opts.VisualMapOpts(max_=20000, min_=500, orient="horizontal", is_piecewise=False), ).render("calendar_heatmap.html")) # 漏斗图 from pyecharts.charts import Funnel