# ## 原创,转载,广告文章数的占比 # In[88]: # 三种类型的文章数 original_num = article[article['是否原创'] == '是'].shape[0] reprint_num = article[article['是否广告'] == '是'].shape[0] advertising_num = article[article['是否转载'] == '是'].shape[0] # 占比圆环图 from pyecharts import options as opts from pyecharts.charts import Pie from pyecharts.globals import ThemeType v = ['原创', '广告', '转载'] c = (Pie(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE, chart_id=1)).add( "", [list(z) for z in zip(v, [original_num, reprint_num, advertising_num])], radius=["40%", "75%"], ).set_global_opts( title_opts=opts.TitleOpts(title="转载,广告,原创占比"), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"), ).set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))) c.render('../output/转载,广告,原创占比.html') c.render_notebook() # ## 文章标题用词状况 # In[89]:
offset=80, axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts( color="#5793f3")), axislabel_opts=opts.LabelOpts(formatter="{value} ml"), ), tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"), legend_opts=opts.LegendOpts(pos_left="65%"), )) line1 = (Line().add_xaxis(["{}月".format(i) for i in range(1, 13)]).add_yaxis( "平均温度 1", [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2], color="#675bba", label_opts=opts.LabelOpts(is_show=False), xaxis_index=1, yaxis_index=5, )) overlap_1 = bar.overlap(line) overlap_2 = bar1.overlap(line1) c = (Grid(init_opts=opts.InitOpts(width="1200px", height="800px")).add( overlap_1, grid_opts=opts.GridOpts(pos_right="58%"), is_control_axis_index=True).add(overlap_2, grid_opts=opts.GridOpts(pos_left="58%"), is_control_axis_index=True)) c.width = "100%" put_html(c.render_notebook())
import pyecharts.options as opts # 导入pyecharts库 from pyecharts.charts import Line num = [0.7073, 0.6472, 0.8294, 0.8315] # 导入数据 num2 = [0.6131, 0.7733, 0.8283, 0.8237] num3 = [0.6256, 0.7551, 0.8286, 0.8269] lab = ["第一阶段", "第二阶段", "第三阶段", "第四阶段"] (Line(init_opts=opts.InitOpts(width='720px', height='320px')) # 指定画布大小,括号内为空则默认大小 .add_xaxis(xaxis_data=lab).add_yaxis("湖北", num).add_yaxis( "其他省份", num2, symbol="triangle").add_yaxis("总体心态", num3, symbol="").set_global_opts( title_opts=opts.TitleOpts(title="积极心态变化图")).set_series_opts( label_opts=opts.LabelOpts(is_show=False))).render('积极心态折线图.html')
}]), xaxis_opts=opts.AxisOpts( grid_index=1, type_="category", boundary_gap=True, position="top", axisline_opts=opts.AxisLineOpts(is_on_zero=True)), yaxis_opts=opts.AxisOpts(is_inverse=False, name="Value", name_gap=25), legend_opts=opts.LegendOpts(pos_bottom='10%', pos_right='50')) # In[11]: grid = Grid(init_opts=opts.InitOpts(width="1024px", height="768px")) grid.add(chart=l1, grid_opts=opts.GridOpts(pos_left=50, pos_right=50, height="35%")) grid.add(chart=l2, grid_opts=opts.GridOpts(pos_left=50, pos_right=50, pos_top="55%", height="35%")) grid.render_notebook() # In[12]: # get_data_yahoo(inst_ticker, start_date, end_date) sp = pdr.get_data_yahoo('^GSPC', '17-Nov-19') ns = pdr.get_data_yahoo('^IXIC', '17-Nov-19')
def day_sxdl(self, x, mc, a, b, c, k): c = (Line( init_opts=opts.InitOpts(width="1000px", height="500px") ).add_xaxis(x).add_yaxis("电压A", a, is_smooth=True).add_yaxis( "电压B", b, is_smooth=True).add_yaxis( "电压C", c, is_smooth=True).set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), title_opts={ 'text': mc, 'subtext': None }, xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=-90), max_interval=366, type_="category", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value} v"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), toolbox_opts=opts. ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( pixel_ratio=2, background_color='white'), restore=opts.ToolBoxFeatureRestoreOpts(is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts( is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts( is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts( is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'), ))).set_series_opts(label_opts=opts.LabelOpts( is_show=False), ).extend_axis( yaxis=opts.AxisOpts(name='方差', axislabel_opts=opts.LabelOpts( formatter="{value} ")))) line1 = Line().add_xaxis(x).add_yaxis( "方差", k, yaxis_index=1, is_smooth=True, linestyle_opts=opts.LineStyleOpts( color="black", width=2, type_="solid")).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ) c.overlap(line1) return c # def day_loss_1(self,x,y,t,st,z,m): # c = self.dayloss_line_base(x,y,t,st) # c = c.extend_axis( # yaxis=opts.AxisOpts( # axislabel_opts=opts.LabelOpts(formatter="{value} kWh") # ) # ).extend_axis( # yaxis=opts.AxisOpts( # name = '数据完整率', # position = 'right', # offset = 62, # axislabel_opts=opts.LabelOpts(formatter="{value} "), # axisline_opts=opts.AxisLineOpts( # linestyle_opts=opts.LineStyleOpts(color="#675bba") # ), # ) # ) # line = Line().add_xaxis(x).add_yaxis("供入电量", z,yaxis_index=1,is_smooth=True).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # line_1 = Line().add_xaxis(x).add_yaxis("数据完整率", m,yaxis_index=2).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # c.overlap(line) # c.overlap(line_1) # return c # def day_loss_2(self,x,y,t,st,a,b): # c = self.dayloss_line_base(x,y,t,st) # c = c.extend_axis( # yaxis=opts.AxisOpts( # axislabel_opts=opts.LabelOpts(formatter="{value} kWh") # ) # ) # line = Line().add_xaxis(a).add_yaxis("用电量", b,yaxis_index=1,is_smooth=True).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # c.overlap(line) # return c # class electricity(): # """docstring for electricity""" # def __init__(self,df): # self.df = df # def day_data(self,a): # tq = self.df[self.df.测量点号==a][['数据时间','正向']].set_index('数据时间').sort_values(by='数据时间') # x = [i[-5:] for i in tq.index] # y = [float(i[0]) for i in tq.values] # t = a # return x,y,t # def measure_num(self): # num = set(i for i in self.df.测量点号) # num = list(num)[1:] # return num # class relation(object): # """docstring for relation""" # def curr_relation(self,x,y,a,b): # lineloss = pd.Series(y,index=x) # day_electricity = pd.Series(b,index= a) # c = lineloss.corr(day_electricity) # # c1 = lineloss.cov(day_electricity) # return c # IO = '石鼓12月.xls' # k = [] # day_loss = data(IO) # tq_index = day_loss.day_lineloss_index() # for i in tq_index: # x,y,a,z,m = data(IO).day_lineloss(i) # nc = relation().curr_relation(x,y,x,z) # c = drawing().day_loss_1(x,y, a+ str(nc),z,m) # k.append(c) # drawing().all_day_lineloss(k,'石鼓12') # IO = '石鼓12月.xls' # name = '宝丰12.xlsx' # num = electricity(name).measure_num() # day_loss = data(IO) # a,b,j,z,m = data(IO).day_lineloss('宝丰公用台变') # k1 = [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # c1 = drawing().day_loss_2(a,b,str(t)+' & '+str(c),x,y) # k1.append(c1) # ny = np.array(electricity(name).day_data(92)[1]) + np.array(electricity(name).day_data(37)[1]) # c = relation().curr_relation(a,b,x,ny) # c1 = drawing().day_loss_2(a,b,'9237'+str(c),x,ny) # k1.append(c1) # drawing().all_day_lineloss(k1,'宝丰12') # k2 = [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # k2.append(c) # print(str(c) + 10*'-'+str(i)) # print(10*'--') # k3 = [] # nyy= [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # print(c[0]) # if c[0] > 0.5: # nyy.append(np.array(y)) # c1 = drawing().day_loss_2(a,b,t,x,y) # k3.append(c1) # c2 = drawing().day_loss_2(a,b,'all',x,sum(nyy)) # k3.append(c2) # drawing().all_day_lineloss(k3,'test_class_5') # c = relation().curr_relation(a,b,x,sum(nyy)) # print(c)
def show_pyecharts(): x_data = [ '0.0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0' ] y_data = [ '1533', '573', '502', '491', '520', '556', '577', '788', '1252', '20564', '6393' ] #情感分析柱状图 bar = (Bar().add_xaxis(x_data).add_yaxis( "情感分析", y_data, label_opts=opts.LabelOpts(is_show=False), color='#3498DB').set_global_opts(title_opts={ "text": "台海舆论情感分析", "subtext": "大于0.5为正面评价,小于0.5为负面评价" })) #台湾网饼图 x_data2 = [ "文化", "经贸", "媒体专栏", "网友专栏", "两岸专家", "两岸", "台商", "部委", "台海时事", "网友快言", "海峡时评", "两岸快评" ] y_data2 = [553, 553, 35, 39, 448, 465, 553, 321, 553, 406, 553, 556] pie = (Pie(init_opts=opts.InitOpts(theme=ThemeType.CHALK)).add( series_name="中国台湾网", data_pair=[list(z) for z in zip(x_data2, y_data2)], radius=["50%", "70%"], label_opts=opts.LabelOpts(is_show=False, position="center"), ).set_colors([ "#E8F8F5", "#D1F2EB", "#A3E4D7", "#76D7C4", "#48C9B0", "#1ABC9C", "#17A589", "#148F77", "#117864", "#0E6251F", "#73C6B6", "#45B39D" ]).set_global_opts(legend_opts=opts.LegendOpts( pos_left="legft", orient="vertical")).set_series_opts( tooltip_opts=opts.TooltipOpts( trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)"), )) #词云图 word = (WordCloud().add( "", list1, word_size_range=[20, 100], shape=SymbolType.DIAMOND, textstyle_opts=opts.TextStyleOpts(font_family="cursive"), )) #折线图1 y2[0], y2[1], y2[2] = None, None, None y4[1] = None line = (Line().add_xaxis(xaxis_data=x1).add_yaxis( series_name="微博", symbol="emptyCircle", is_symbol_show=True, color="#F2D7D5", y_axis=y1, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="环球网", symbol="emptyCircle", is_symbol_show=True, color="#C0392B", y_axis=y2, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="中国台湾网", symbol="emptyCircle", is_symbol_show=True, color="#641E16", y_axis=y3, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="知乎", symbol="emptyCircle", is_symbol_show=True, color="#9B59B6", y_axis=y4, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="中国日报网", symbol="emptyCircle", is_symbol_show=True, color="#512E5F", y_axis=y5, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="中新网", symbol="emptyCircle", is_symbol_show=True, color="#2980B9", y_axis=y6, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)). add_yaxis( series_name="今日头条", symbol="emptyCircle", is_symbol_show=True, color="#154360", y_axis=y7, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="光明网", symbol="emptyCircle", is_symbol_show=True, color="#3498DB", y_axis=y8, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="凤凰网", symbol="emptyCircle", is_symbol_show=True, color="#1ABC9C", y_axis=y9, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis( series_name="新华网", symbol="emptyCircle", is_symbol_show=True, color="#0E6251", y_axis=y10, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts( width=3)).set_global_opts( tooltip_opts=opts.TooltipOpts( trigger="axis"), 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, axisline_opts=opts.AxisLineOpts( is_on_zero=False, linestyle_opts=opts.LineStyleOpts( color="#d14a61"))), )) #平台占比饼图 x_data3 = [ "微博", "知乎", "中国台湾网", "环球网", "日报网", "中新网", "今日头条", "光明网", "凤凰网", "新华网" ] y_data3 = [5401, 157, 5035, 3245, 4296, 5574, 1891, 3131, 1052, 1997] data_pair = [list(z) for z in zip(x_data3, y_data3)] data_pair.sort(key=lambda x: x[1]) pie2 = (Pie(init_opts=opts.InitOpts(theme=ThemeType.ROMA)).add( series_name="访问来源", data_pair=data_pair, rosetype="radius", radius="55%", center=["50%", "50%"], label_opts=opts.LabelOpts(is_show=False, position="center"), ).set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{d}%"))) #折线图2 line2 = (Line().add_xaxis(xaxis_data=x_data4).add_yaxis( series_name="热度走势", y_axis=y_data4, color="#FF69B4", markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(type_="max")]), symbol="emptyCircle", is_symbol_show=True, is_smooth=True, label_opts=opts.LabelOpts(is_show=True), ).set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=False), 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, axislabel_opts=opts.LabelOpts(rotate=45)), )) #条形图 line3 = (Bar().add_xaxis(x_data5).add_yaxis( "平均值", y_data5, label_opts=opts.LabelOpts(is_show=False), color='#6A5ACD').reversal_axis().extend_axis(yaxis=opts.AxisOpts( type_='value', name='转发次数', position='left', )).set_global_opts( title_opts={"text": "评论与转发关系图"}, xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts( formatter='{value}(评论数量)')), )) #圆 radius = (Polar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)).add_schema( radiusaxis_opts=opts.RadiusAxisOpts(data=x_data6, type_="category"), angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True, max_=100000), ).add("点赞数量", y_data6, type_="bar").set_global_opts( title_opts=opts.TitleOpts(title="")).set_series_opts( label_opts=opts.LabelOpts(is_show=True))) return render_template("index2.html", bar_data=bar.dump_options(), word_data=word.dump_options(), pie_data=pie.dump_options(), pie2_data=pie2.dump_options(), line_data=line.dump_options(), line2_data=line2.dump_options(), line3_data=line3.dump_options(), radius_data=radius.dump_options())
137.7008290515613, 199.78999859299336, ], [ 0.5370189113081292, 50.44519588101707, 98.08928065026996, 139.8482090057953, 197.20820681141507, ], ], "outliers": [], }, ] (Boxplot(init_opts=opts.InitOpts(width="1600px", height="800px")).add_xaxis( xaxis_data=axis_data).add_yaxis( series_name="category0", y_axis=data[0]["boxData"], tooltip_opts=opts.TooltipOpts( formatter=JsCode("""function(param) { return [ 'Experiment ' + param.name + ': ', 'upper: ' + param.data[0], 'Q1: ' + param.data[1], 'median: ' + param.data[2], 'Q3: ' + param.data[3], 'lower: ' + param.data[4] ].join('<br/>') }""")), ).add_yaxis( series_name="category1", y_axis=data[1]["boxData"],
import pyecharts.options as opts from pyecharts.charts import MapGlobe from pyecharts.faker import POPULATION data = [x for _, x in POPULATION[1:]] low, high = min(data), max(data) c = ( MapGlobe(init_opts=opts.InitOpts(width='1800px', height='960px', bg_color='#00BBFF')) # .add_schema().add( maptype="world", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=True, label_opts=opts.LabelOpts(is_show=True), ).set_global_opts( title_opts=opts.TitleOpts(title="3D 地球示例"), # 设置地球属性 visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, range_color=["lightskyblue", "yellow", "orangered"], )).render("world_map_3d.html"))
) ) pie = ( Pie() .add( "", [list(z) for z in zip(x, ys[i])], radius=[60, 0], center=["70%", "20%"], label_opts=opts.LabelOpts(is_show=False) ) .set_global_opts( legend_opts=opts.LegendOpts( type_="scroll", pos_top="10%", pos_left="80%", orient="vertical" ), ) ) grid = ( Grid(init_opts=opts.InitOpts(width="1800px", height="800px")) .add(bar, grid_opts=opts.GridOpts(pos_left="5%", width=500, height=200)) .add(pie, grid_opts=opts.GridOpts(pos_right="0%", pos_top='80%', width=200, height=250)) ) tl.add(grid, time[i]) tl.add_schema( pos_top="55%", pos_left='0%', label_opts=opts.LabelOpts(rotate=45,position='Bottom',interval=None,horizontal_align='left',distance=0) ) tl.render("tabRE.html")
import pyecharts.options as opts from pyecharts.charts import Radar """ Gallery 使用 pyecharts 1.1.0 参考地址: https://echarts.apache.org/examples/editor.html?c=radar 目前无法实现的功能: 1、雷达图周围的图例的 textStyle 暂时无法设置背景颜色 """ v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] (Radar(init_opts=opts.InitOpts(bg_color="#CCCCCC")).add_schema( schema=[ opts.RadarIndicatorItem(name="销售(sales)", max_=6500), opts.RadarIndicatorItem(name="管理(Administration)", max_=16000), opts.RadarIndicatorItem(name="信息技术(Information Technology)", max_=30000), opts.RadarIndicatorItem(name="客服(Customer Support)", max_=38000), opts.RadarIndicatorItem(name="研发(Development)", max_=52000), opts.RadarIndicatorItem(name="市场(Marketing)", max_=25000), ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ).add( series_name="预算分配(Allocated Budget)", data=v1, linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ).add(
""" Gallery 使用 pyecharts 1.1.0 参考地址: https://www.echartsjs.com/examples/editor.html?c=line-marker 目前无法实现的功能: 1、最低气温的最高值暂时无法和 Echarts 的示例完全复刻 """ week_name_list = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"] high_temperature = [11, 11, 15, 13, 12, 13, 10] low_temperature = [1, -2, 2, 5, 3, 2, 0] ( Line(init_opts=opts.InitOpts(width="1600px", height="800px")) .add_xaxis(xaxis_data=week_name_list) .add_yaxis( series_name="最高气温", y_axis=high_temperature, markpoint_opts=opts.MarkPointOpts( data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ] ), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")] ), ) .add_yaxis(
ql.cursor = ql.conn.cursor(cursor=ql.pymysql.cursors.DictCursor) sql = 'select date, start_price, max_price, min_price, stop_price from abc001_defect;' ql.cursor.execute(sql) ret = ql.cursor.fetchall() print(ret) x_data = [] y_data = [] for i in ret: str_date = datetime.datetime.strftime(i['date'], '%Y-%m-%d') x_data.append(str_date) y_data.append( [i['start_price'], i['max_price'], i['min_price'], i['stop_price']]) c = (Kline(init_opts=opts.InitOpts(width="1440px", height="800px")).add_xaxis( xaxis_data=x_data).add_yaxis( "kline", y_data, itemstyle_opts=opts.ItemStyleOpts( color="#ec0000", color0="#00da3c", border_color="#8A0000", border_color0="#008F28", ), ).set_global_opts( xaxis_opts=opts.AxisOpts(is_scale=True), yaxis_opts=opts.AxisOpts( is_scale=True, splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)),
def barChart(df): type_of_plot = st.selectbox("Select Type of Plot", ["BAR1", "BAR2", "BAR3", "BAR4", "BAR5"]) all_columns = df.columns #st.success("Generating Customizable Plot of {} for {}".format(type_of_plot)) if type_of_plot == 'BAR1': columns_to_plot = st.selectbox("Select 1 column", all_columns, key='a') columns_to_plot1 = st.selectbox("Select 2 column", all_columns, key='b') columns_to_plot2 = st.selectbox("Select 3 column", all_columns, key='c') cje = df[columns_to_plot].tolist() other_var = df[columns_to_plot1].tolist() other_var1 = df[columns_to_plot2].tolist() bar = Bar(init_opts=opts.InitOpts(width='900px', height='1200px')) bar.add_xaxis(cje) bar.add_yaxis(columns_to_plot1, other_var) bar.add_yaxis(columns_to_plot2, other_var1) bar.set_global_opts(toolbox_opts=opts.ToolboxOpts()) bar.reversal_axis() bar.set_series_opts( label_opts=opts.LabelOpts(position="right"), markline_opts=opts.MarkLineOpts(data=[ opts.MarkLineItem(type_="min", name="最小值"), opts.MarkLineItem(type_="max", name="最大值"), opts.MarkLineItem(type_="average", name="平均值"), ]), ) #bar.set_global_opts(title_opts=opts.TitleOpts(title="Bar-Test Rendered Pictures")) # st.button("Generate Plot") return bar if type_of_plot == 'BAR2': columns_to_plot = st.selectbox("Select 1 column", all_columns, key='a') columns_to_plot1 = st.selectbox("Select 2 column", all_columns, key='b') cje = df[columns_to_plot].tolist() other_var = df[columns_to_plot1].tolist() bar = Bar(init_opts=opts.InitOpts(width='900px', height='1800px')) bar.add_xaxis(cje) bar.add_yaxis(columns_to_plot1, other_var, gap="0%") bar.set_global_opts( toolbox_opts=opts.ToolboxOpts(), xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=65)), brush_opts=opts.BrushOpts()) bar.set_series_opts(markline_opts=opts.MarkLineOpts(data=[ opts.MarkLineItem(type_="min", name="最小值"), opts.MarkLineItem(type_="max", name="最大值"), opts.MarkLineItem(type_="average", name="平均值"), ]), ) return bar if type_of_plot == 'BAR3': columns_to_plot = st.selectbox("Select 1 column", all_columns, key='a') columns_to_plot1 = st.selectbox("Select 2 column", all_columns, key='b') columns_to_plot2 = st.selectbox("Select 3 column", all_columns, key='c') columns_to_plot3 = st.selectbox("Select 4 column", all_columns, key='d') columns_to_plot4 = st.selectbox("Select 5 column", all_columns, key='e') cje = df[columns_to_plot].tolist() other_var1 = df[columns_to_plot1].tolist() other_var2 = df[columns_to_plot2].tolist() other_var3 = df[columns_to_plot3].tolist() other_var4 = df[columns_to_plot4].tolist() bar = Bar(init_opts=opts.InitOpts(width='900px', height='1200px')) bar.add_xaxis(cje) bar.add_yaxis(columns_to_plot1, other_var1) bar.add_yaxis(columns_to_plot2, other_var2) bar.add_yaxis(columns_to_plot3, other_var3) bar.add_yaxis(columns_to_plot4, other_var4) bar.reversal_axis() #bar.add_yaxis(columns_to_plot1, other_var, gap="0%") bar.set_global_opts( toolbox_opts=opts.ToolboxOpts(), xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=65)), brush_opts=opts.BrushOpts()) grid = Grid() grid.add(bar, grid_bottom="60%") return bar
#%% md ### 商品销量排名top10 - 柱形图 #%% # 导入包 from pyecharts.charts import Bar from pyecharts import options as opts # 计算top10店铺 shop_top10 = df.groupby('商品名')['销量'].sum().sort_values( ascending=False).head(10) # 绘制柱形图 bar0 = Bar(init_opts=opts.InitOpts(width='1350px', height='750px')) bar0.add_xaxis(shop_top10.index.tolist()) bar0.add_yaxis('sales_num', shop_top10.values.tolist()) bar0.set_global_opts( title_opts=opts.TitleOpts(title='粽子商品销量Top10'), xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)), visualmap_opts=opts.VisualMapOpts(max_=shop_top10.values.max())) bar0.render("粽子商品销量Top10.html") #%% md ### 店铺销量排名top10 - 柱形图 #%% # 导入包
def pyecharts(request): """dashboard view""" # 工单数量统计 chart_dao = ChartDao() data = chart_dao.workflow_by_date(30) today = date.today() one_month_before = today - relativedelta(days=+30) attr = chart_dao.get_date_list(one_month_before, today) _dict = {} for row in data['rows']: _dict[row[0]] = row[1] value = [_dict.get(day) if _dict.get(day) else 0 for day in attr] bar1 = Bar(init_opts=opts.InitOpts(width='600', height='380px')) bar1.add_xaxis(attr) bar1.add_yaxis("", value) # 工单按组统计 data = chart_dao.workflow_by_group(30) attr = [row[0] for row in data['rows']] value = [row[1] for row in data['rows']] pie1 = Pie(init_opts=opts.InitOpts(width='600', height='380px')) pie1.set_global_opts(title_opts=opts.TitleOpts(title=''), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%", is_show=False)) pie1.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) pie1.add("", [list(z) for z in zip(attr, value)]) # 工单按人统计 data = chart_dao.workflow_by_user(30) attr = [row[0] for row in data['rows']] value = [row[1] for row in data['rows']] bar2 = Bar(init_opts=opts.InitOpts(width='600', height='380px')) bar2.add_xaxis(attr) bar2.add_yaxis("", value) # SQL语句类型统计 data = chart_dao.syntax_type() attr = [row[0] for row in data['rows']] value = [row[1] for row in data['rows']] pie2 = Pie() pie2.set_global_opts(title_opts=opts.TitleOpts(title='SQL上线工单统计(类型)'), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%")) pie2.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) pie2.add("", [list(z) for z in zip(attr, value)]) # SQL查询统计(每日检索行数) attr = chart_dao.get_date_list(one_month_before, today) effect_data = chart_dao.querylog_effect_row_by_date(30) effect_dict = {} for row in effect_data['rows']: effect_dict[row[0]] = int(row[1]) effect_value = [ effect_dict.get(day) if effect_dict.get(day) else 0 for day in attr ] count_data = chart_dao.querylog_count_by_date(30) count_dict = {} for row in count_data['rows']: count_dict[row[0]] = int(row[1]) count_value = [ count_dict.get(day) if count_dict.get(day) else 0 for day in attr ] line1 = Line(init_opts=opts.InitOpts(width='600', height='380px')) line1.set_global_opts(title_opts=opts.TitleOpts(title=''), legend_opts=opts.LegendOpts(selected_mode='single')) line1.add_xaxis(attr) line1.add_yaxis("检索行数", effect_value, is_smooth=True, markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(type_="average")])) line1.add_yaxis("检索次数", count_value, is_smooth=True, markline_opts=opts.MarkLineOpts(data=[ opts.MarkLineItem(type_="max"), opts.MarkLineItem(type_="average") ])) # SQL查询统计(用户检索行数) data = chart_dao.querylog_effect_row_by_user(30) attr = [row[0] for row in data['rows']] value = [int(row[1]) for row in data['rows']] pie4 = Pie(init_opts=opts.InitOpts(width='600', height='380px')) pie4.set_global_opts(title_opts=opts.TitleOpts(title=''), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%", is_show=False)) pie4.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) pie4.add("", [list(z) for z in zip(attr, value)]) # SQL查询统计(DB检索行数) data = chart_dao.querylog_effect_row_by_db(30) attr = [row[0] for row in data['rows']] value = [int(row[1]) for row in data['rows']] pie5 = Pie(init_opts=opts.InitOpts(width='600', height='380px')) pie5.set_global_opts(title_opts=opts.TitleOpts(title=''), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%", is_show=False)) pie5.set_series_opts( label_opts=opts.LabelOpts(formatter="{b}: {c}", position="left")) pie5.add("", [list(z) for z in zip(attr, value)]) # 慢查询db/user维度统计(最近1天) data = chart_dao.slow_query_count_by_db_by_user(1) attr = [row[0] for row in data['rows']] value = [int(row[1]) for row in data['rows']] pie3 = Pie(init_opts=opts.InitOpts(width='600', height='380px')) pie3.set_global_opts(title_opts=opts.TitleOpts(title=''), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%", is_show=False)) pie3.set_series_opts( label_opts=opts.LabelOpts(formatter="{b}: {c}", position="left")) pie3.add("", [list(z) for z in zip(attr, value)]) # 慢查询db维度统计(最近1天) data = chart_dao.slow_query_count_by_db(1) attr = [row[0] for row in data['rows']] value = [row[1] for row in data['rows']] bar3 = Bar(init_opts=opts.InitOpts(width='600', height='380px')) bar3.add_xaxis(attr) bar3.add_yaxis("", value) # 可视化展示页面 chart = { "bar1": bar1.render_embed(), "pie1": pie1.render_embed(), "bar2": bar2.render_embed(), "bar3": bar3.render_embed(), "pie2": pie2.render_embed(), "line1": line1.render_embed(), "pie3": pie3.render_embed(), "pie4": pie4.render_embed(), "pie5": pie5.render_embed(), } # 获取统计数据 dashboard_count_stats = { "sql_wf_cnt": SqlWorkflow.objects.count(), "query_wf_cnt": QueryPrivilegesApply.objects.count(), "user_cnt": Users.objects.count(), "ins_cnt": Instance.objects.count() } return render(request, "dashboard.html", { "chart": chart, "count_stats": dashboard_count_stats })
# 使用 defaultdict 统计出电影种类和对应电影数 counter = defaultdict(int) for genre in genres: for e in genre: counter[e] += 1 print(counter) # 一共有 29 种电影,对上面字典按种类数排序 counter_sorted = sorted(counter.items(), key=lambda x: x[1]) print(counter_sorted) # 取电影种类数最多的前 10 进行分析 top10 = counter_sorted[-10:] # 绘制前 10 最多种类数的柱状图,使用 pyecharts 绘制 x = [x for x, y in top10] y = [y for x, y in top10] bar = ( Bar(init_opts=opts.InitOpts(height='1200px')) .add_xaxis(x) .add_yaxis('电影种类名', y, category_gap='50%') .reversal_axis() .set_global_opts(title_opts=opts.TitleOpts(title="电影种类及影片数"), toolbox_opts=opts.ToolboxOpts()) ) grid = ( Grid(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) .add(bar, grid_opts=opts.GridOpts(pos_left="30%")) ) grid.render(path='./语法基础/res/html/movie1.html') c = ( Pie() .add(
line2.add_yaxis( series_name='疑似数', y_axis=suspect_num, color='#fed0fc', # 标签配置 label_opts=opts.LabelOpts(is_show=False), # 线 linestyle_opts=opts.LineStyleOpts(width=1.2, color='#fed0fc')) # 合并两个图 sumx = bar.overlap(line1).overlap(line2) # 组合 all_ = Grid(init_opts=opts.InitOpts( width='1750px', # 宽度 height='654px', # 高度 theme=ThemeType.PURPLE_PASSION, )) all_.add( sumx, grid_opts=opts.GridOpts(pos_left='5%', pos_top='20%', pos_right='40%'), is_control_axis_index=True, ) # 生成 all_.render('./conv-19.html') # 1、绘制2个柱状图 ---应该添加 3个新纵轴、 修改1个原来的纵轴(全局配置项) # 2、绘制1个折线图 # 3、再绘制1个折线图
'M' k线+MACD FieldName: string Dataframe中的字段名 [Field1,Field2,...] Dataframe中的字段名列表,将显示在一个区域 width: int #图表宽度 px height:int #图表高度 px klines:list #K线区域显示的数据,Dataframe中的字段名,如MA... vline: list #Volume区域显示的数据,Dataframe中的字段名,如MA... - sample: chart=data.plot(area=[['small_pct','medium_pct','big_pct','super_pct'],'V','cci'],vlines=['vMA5','vMA10'],klines=['MA5','MA10']) ''' self.klines=klines self.vlines=vlines grid = ( Grid(init_opts=opts.InitOpts( width=str(width)+"px", height=str(height)+"px", animation_opts=opts.AnimationOpts(animation=False), ) ) ) c=self.K() iTop=10 iButton=10 iWindows=len(area) iStep=0 if iWindows==0: grid.add(c, grid_opts=opts.GridOpts(pos_top="2%",pos_bottom="10%")) elif iWindows>1: grid.add(c, grid_opts=opts.GridOpts(pos_top="2%",pos_bottom="50%")) iStep=int(30/iWindows) iButton=50
import pyecharts from pyecharts.charts import Bar # 柱状图 from pyecharts import options as ops from pyecharts.globals import ThemeType # 内置主题类型 bar = ( Bar(init_opts=ops.InitOpts(theme="")).add_xaxis( ["xxx", "juice", "14", "ts", "drake", "young thug"]).add_yaxis("商家A", [100, 20, 36, 10, 75, 90]) # 全局配置项 .set_global_opts( # 标题配置项 title_opts=ops.TitleOpts( # 主标题 title="hello", subtitle="hhh"), # 图例配置项 legend_opts=ops.LegendOpts(is_show=True), # 工具配置项 toolbox_opts=ops.ToolboxOpts(is_show=False), # 视觉映射配置项 visualmap_opts=ops.VisualMapOpts(is_show=True, # type_="color" ))) bar.render("柱状图.html") # 使用 options 配置项,在 pyecharts 中,一切皆 Options。 # 全局配置项可通过 set_global_opts 方法设置
"合肥": [117.27, 31.86], "武汉": [114.31, 30.52], "大庆": [125.03, 46.58], } def convert_data(): res = [] for i in range(len(data)): geo_coord = geoCoordMap[data[i][0]] geo_coord.append(data[i][1]) res.append([data[i][0], geo_coord]) return res (BMap(init_opts=opts.InitOpts(width="1400px", height="800px")).add( type_="effectScatter", series_name="已点亮人数", data_pair=convert_data(), symbol_size=10, effect_opts=opts.EffectOpts(), label_opts=opts.LabelOpts(formatter="{b}", position="right", is_show=False), itemstyle_opts=opts.ItemStyleOpts(color="white"), ).add_schema( baidu_ak="FAKE_AK", center=[104.114129, 37.550339], zoom=5, is_roam=True, map_style={ "styleJson": [
else: break return temp def surface3d_data(): for t0 in float_range(-3, 3, 0.05): y = t0 for t1 in float_range(-3, 3, 0.05): x = t1 z = math.sin(x ** 2 + y ** 2) * x / 3.14 yield [x, y, z] ( Surface3D(init_opts=opts.InitOpts(width="1600px", height="800px")) .add( series_name="", shading="color", data=list(surface3d_data()), xaxis3d_opts=opts.Axis3DOpts(type_="value"), yaxis3d_opts=opts.Axis3DOpts(type_="value"), grid3d_opts=opts.Grid3DOpts(width=100, height=40, depth=100), ) .set_global_opts( visualmap_opts=opts.VisualMapOpts( dimension=2, max_=1, min_=-1, range_color=[ "#313695",
def plot_lines(self, x_data, y_data, filename_, series_name='x1_dist'): filename = self.plot_line_path + filename_ background_color_js = ( "new echarts.graphic.LinearGradient(0, 0, 0, 1, " "[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)" ) area_color_js = ( "new echarts.graphic.LinearGradient(0, 0, 0, 1, " "[{offset: 0, color: '#eb64fb'}, {offset: 1, color: '#3fbbff0d'}], false)" ) c = (Line( init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)) ).add_xaxis(xaxis_data=x_data).add_yaxis( series_name=series_name, y_axis=y_data, is_smooth=True, is_symbol_show=True, symbol="circle", symbol_size=6, linestyle_opts=opts.LineStyleOpts(color="#fff"), label_opts=opts.LabelOpts(is_show=True, position="top", color="white"), itemstyle_opts=opts.ItemStyleOpts(color="red", border_color="#fff", border_width=3), tooltip_opts=opts.TooltipOpts(is_show=False), areastyle_opts=opts.AreaStyleOpts(color=JsCode(area_color_js), opacity=1), ).set_global_opts( title_opts=opts.TitleOpts( title="show %s in one image" % series_name, pos_top="5%", pos_left="center", title_textstyle_opts=opts.TextStyleOpts(color="#fff", font_size=16), ), xaxis_opts=opts.AxisOpts( type_="category", boundary_gap=False, axislabel_opts=opts.LabelOpts(margin=30, color="#ffffff63"), axisline_opts=opts.AxisLineOpts(is_show=False), axistick_opts=opts.AxisTickOpts( is_show=True, length=25, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"), ), splitline_opts=opts.SplitLineOpts( is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")), ), yaxis_opts=opts.AxisOpts( type_="value", position="right", axislabel_opts=opts.LabelOpts(margin=20, color="#ffffff63"), axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts(width=2, color="#fff")), axistick_opts=opts.AxisTickOpts( is_show=True, length=15, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"), ), splitline_opts=opts.SplitLineOpts( is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")), ), datazoom_opts=[ opts.DataZoomOpts(range_start=0, range_end=100), opts.DataZoomOpts(type_="inside", range_start=0, range_end=100), ], legend_opts=opts.LegendOpts(is_show=False), )) c.render(filename)
""" * @File: 05-使用主题.py * @Author: CSY - 25809 * @Date: 2020/5/27 - 16:54 * @Project: Python """ from pyecharts.charts import Bar from pyecharts import options as opts # 内置主题类型可查看 pyecharts.globals.ThemeType from pyecharts.globals import ThemeType bar = (Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)).add_xaxis( ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]).add_yaxis("商家A", [5, 20, 36, 10, 75, 90]).add_yaxis( "商家B", [15, 6, 45, 20, 35, 66]).set_global_opts( title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))) bar.render()
map_chart = get_Map(time, data) bar_chart = get_Bar(time, data) g = (Grid(init_opts=opts.InitOpts(width='1440px', height='600px')).add( bar_chart, grid_opts=opts.GridOpts(pos_left="10", pos_right="45%", pos_top="50%", pos_bottom="10")).add( map_chart, grid_opts=opts.GridOpts())) return g if __name__ == '__main__': data = read_file('test1.csv') data = data_clear(data) timeline = Timeline(init_opts=opts.InitOpts( width="1440px", height="600px", theme=ThemeType.DARK)) for y in data.keys(): g = get_year_chart(y, data) timeline.add(g, time_point=str(y)) timeline.add_schema( orient="vertical", is_auto_play=True, is_inverse=True, play_interval=500, pos_left="null", pos_right="5", pos_top="20", pos_bottom="20", width="60", label_opts=opts.LabelOpts(is_show=True, color="#fff"), )
def draw(datelist, pricelist, title): min_value = min(pricelist) max_value = max(pricelist) line = ( Line(init_opts=opts.InitOpts( width='1800px', height='800px', js_host="./", )) .set_global_opts( title_opts=opts.TitleOpts( title=title, # subtitle='股票价格走势' ), legend_opts=opts.LegendOpts( is_show=True, pos_top=10, pos_left="center", item_width=30, item_height=15, textstyle_opts=opts.TextStyleOpts( font_family='Microsoft Yahei', font_size=14, font_style='oblique' ) ), tooltip_opts=opts.TooltipOpts( trigger="axis", axis_pointer_type="cross", background_color="rgba(245, 245, 245, 0.8)", border_width=1, border_color="#ccc", textstyle_opts=opts.TextStyleOpts(color="#000"), ), xaxis_opts=opts.AxisOpts( # type_="time", name='日期', split_number=10, name_gap=35, axispointer_opts=opts.AxisPointerOpts(is_show=True), name_textstyle_opts=opts.TextStyleOpts( font_size=16, font_family='Microsoft Yahei' ) ), yaxis_opts=opts.AxisOpts( type_="value", # name='价格', min_=min_value, max_=max_value, split_number=4, axispointer_opts=opts.AxisPointerOpts(is_show=True), name_textstyle_opts=opts.TextStyleOpts( font_size=16, font_family='Microsoft Yahei' ), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), splitarea_opts=opts.SplitAreaOpts(is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)) ), axispointer_opts=opts.AxisPointerOpts( is_show=True, link=[{"xAxisIndex": "all"}], label=opts.LabelOpts(background_color="#777"), ), datazoom_opts=[ opts.DataZoomOpts( is_show=False, type_="inside", # xaxis_index=[0, 1], range_start=30, range_end=70, ), opts.DataZoomOpts( is_show=True, # xaxis_index=[0, 1], type_="slider", pos_top="96%", range_start=38, range_end=70, ), ], ) .add_xaxis(xaxis_data=datelist) .add_yaxis(series_name="走势情况", is_selected=True, y_axis=pricelist, label_opts=opts.LabelOpts(is_show=False) ) .render(title + '.html') )
def get(self): uuid = self.get_argument('uuid', None) deviceinfo = self.session.query( ShorturlOverview.short_url_access_connectType.label('device'), func.count(ShorturlOverview.short_url_id)).filter( ShortUrlInfo.uuid == uuid).filter( ShortUrlInfo.short_code == ShorturlOverview.short_url).group_by('device').all() osinfo = self.session.query( ShorturlOverview.short_url_access_osType.label('osinfo'), func.count(ShorturlOverview.short_url_id)).filter( ShortUrlInfo.uuid == uuid).filter( ShortUrlInfo.short_code == ShorturlOverview.short_url).group_by('osinfo').all() inner_data_pair = [] for device_data in deviceinfo: dinfolist_item = [] dinfolist_item.append(device_data[0]) dinfolist_item.append(device_data[1]) inner_data_pair.append(dinfolist_item) outer_data_pair = [] for os_data in osinfo: os_data_item = [] os_data_item.append(os_data[0]) os_data_item.append(os_data[1]) outer_data_pair.append(os_data_item) pie = Pie() pie.add( series_name="Device From", data_pair=inner_data_pair, radius=[0, "30%"], label_opts=opts.LabelOpts(position="inner"), ) pie.add( series_name="OS Type From", radius=["40%", "55%"], data_pair=outer_data_pair, label_opts=opts.LabelOpts( position="outside", formatter="{a|{a}}{abg|}\n{hr|}\n {b|{b}: }{c} {per|{d}%} ", background_color="#eee", border_color="#aaa", border_width=1, border_radius=4, rich={ "a": { "color": "#999", "lineHeight": 22, "align": "center" }, "abg": { "backgroundColor": "#e3e3e3", "width": "100%", "align": "right", "height": 22, "borderRadius": [4, 4, 0, 0], }, "hr": { "borderColor": "#aaa", "width": "100%", "borderWidth": 0.5, "height": 0, }, "b": { "fontSize": 16, "lineHeight": 33 }, "per": { "color": "#eee", "backgroundColor": "#334455", "padding": [2, 4], "borderRadius": 2, }, }, ), ) pie.set_global_opts( legend_opts=opts.LegendOpts(pos_left="left", orient="vertical"), title_opts=opts.TitleOpts(title="Link Access Device Statistics", pos_right="center"), ) pie.set_series_opts(label_opts=opts.LabelOpts(is_show=False), init_opts=opts.InitOpts(width="800px", height="400px"), tooltip_opts=opts.TooltipOpts( trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)")) pie.render(path=settings['template_path'] + '/pie.html', encoding='utf-8') self.render('pie.html')
"itemStyle": { "color": "#e75b68" } }, { "name": "Sweet Aromatics", "value": 1, "itemStyle": { "color": "#d0545f" } }, ], }, ] c = (Sunburst(init_opts=opts.InitOpts(width="1000px", height="600px")).add( "", data_pair=data, highlight_policy="ancestor", radius=[0, "95%"], sort_="null", levels=[ {}, { "r0": "15%", "r": "35%", "itemStyle": { "borderWidth": 2 }, "label": { "rotate": "tangential"
3D 地球 """ import pyecharts.options as opts from pyecharts.faker import POPULATION from pyecharts.charts import MapGlobe, Grid from pyecharts.globals import ThemeType high = max([x for _, x in POPULATION[1:]]) low = min([x for _, x in POPULATION[1:]]) m = ( MapGlobe(init_opts=opts.InitOpts( width="1920px", height="900px", page_title="全球互联网网络地图", theme=ThemeType.WALDEN)).add_schema().add( maptype="world", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=False, label_opts=opts.LabelOpts(is_show=False), ).set_global_opts( # title_opts=opts.TitleOpts(title="全球互联网网络AS号分布图"), visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, # is_piecewise=True,
def trans_data_to_use(dataset: list): size = len(dataset) # 元组中可能数据大小不一致,因此先进行转化 dataset = np.array(dataset) k = 1 / 1024 # 得到测试的时刻 x_data = dataset[:, 10] y_data_1 = np.array(dataset[:, 1], float) * k y_data_1 = np.round(y_data_1, decimals=1) y_data_2 = np.array(dataset[:, 2], float) * k y_data_2 = np.round(y_data_2, decimals=1) y_data_3 = np.array(dataset[:, 3], float) * k y_data_3 = np.round(y_data_3, decimals=1) y_data_4 = np.array(dataset[:, 4], float) * k y_data_4 = np.round(y_data_4, decimals=1) y_data_5 = np.array(dataset[:, 5], float) * k y_data_5 = np.round(y_data_5, decimals=1) y_data_6 = np.array(dataset[:, 6], float) * k y_data_6 = np.round(y_data_6, decimals=1) y_data_7 = np.array(dataset[:, 7], float) * k y_data_7 = np.round(y_data_7, decimals=1) y_data_8 = np.array(dataset[:, 8], float) * k y_data_8 = np.round(y_data_8, decimals=1) (Line(init_opts=opts.InitOpts(width="1600px", height="800px")).add_xaxis( xaxis_data=x_data).add_yaxis( series_name="java_heap", y_axis=y_data_1, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="native_heap", y_axis=y_data_2, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="code", y_axis=y_data_3, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="stack", y_axis=y_data_4, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="graphics", y_axis=y_data_5, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="private_other", y_axis=y_data_6, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="system", y_axis=y_data_7, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).add_yaxis( series_name="total", y_axis=y_data_8, markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")]), ).set_global_opts( title_opts=opts.TitleOpts(title="memory information", pos_left="center"), tooltip_opts=opts.TooltipOpts(trigger="item", formatter="{a} <br/>{b} : {c}"), legend_opts=opts.LegendOpts(pos_left="left"), xaxis_opts=opts.AxisOpts(type_="category", name="x"), yaxis_opts=opts.AxisOpts( type_="log", name="y", splitline_opts=opts.SplitLineOpts(is_show=True), is_scale=True, ), ).render("memory2.html"))
"Latin": 9, "Religious": 10, "New Age": 11, "International": 12, "Classical": 13, "Avant-Garde": 14, } for key in cc: cat.append({"name": key, "symbol": "circle"}) # %% c = ( Graph( init_opts=opts.InitOpts(width="100%", height="700px", renderer="canvas" # 渲染模式 svg 或 canvas,即 RenderType.CANVAS 或 RenderType.SVG ), ).add( "", nodes_data, links_data, categories=cat, repulsion=50, linestyle_opts=opts.LineStyleOpts(curve=0.2), label_opts=opts.LabelOpts(is_show=False), edge_symbol=['none', 'arrow'], is_draggable=True ).set_global_opts( legend_opts=opts.LegendOpts(is_show=False), # title_opts=opts.TitleOpts(title="Graph-GraphNode-GraphLink-WithEdgeLabel"),