def bar_base() -> Scatter3D: c = ( Scatter3D(init_opts=opts.InitOpts( width="1440px", height="720px")) # bg_color="black" .add( series_name="", data=data, xaxis3d_opts=opts.Axis3DOpts( name=config_xAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), yaxis3d_opts=opts.Axis3DOpts( name=config_yAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), zaxis3d_opts=opts.Axis3DOpts( name=config_zAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ) # .render("scatter3d.html") ) return c
def test_scatter3d_base(): data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] c = (Scatter3D().add("", data).set_global_opts( visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color))) eq_(c.theme, "white") eq_(c.renderer, "canvas") c.render()
def scatter3d_base() -> Scatter3D: data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] c = (Scatter3D().add("", data).set_global_opts( title_opts=opts.TitleOpts("Scatter3D-基本示例"), visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color), )) return c
def test_scatter3d_base(): data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] c = (Scatter3D().add("", data).set_global_opts( visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color))) assert c.theme == "white" assert c.renderer == "canvas" c.render("render.html")
def test_scatter3d_base(fake_writer): data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] c = (Scatter3D().add("", data).set_global_opts( visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color))) c.render() _, content = fake_writer.call_args[0] assert_equal(c.theme, "white") assert_equal(c.renderer, "canvas")
def scatter3d_base() -> Scatter3D: Oth = Other_Url.objects.exclude(power='获取失败').exclude(server='获取失败').values() data = [] for o in Oth: data.append([o.get('power'),o.get('server'),o.get('status')]) c = ( Scatter3D() .add("请求响应数据统计", data) .set_global_opts( title_opts=opts.TitleOpts(), visualmap_opts=opts.VisualMapOpts(range_color=["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026",]), ) ) return c
def a_scatter(): data = [[ random.randint(0, 100), random.randint(0, 80), random.randint(0, 70) ] for i in range(80)] sc = (Scatter3D().add('', data, grid3d_opts=op.Grid3DOpts( rotate_speed=150, is_rotate=True)).set_global_opts( title_opts={'text': '3D散点图'}, visualmap_opts=op.VisualMapOpts( range_color=Faker.visual_color))) return sc
def scatter3d_muti_visualmap_channel(): data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] c = (Scatter3D().add("", data).set_global_opts( title_opts=opts.TitleOpts("Scatter3D-多视觉映射通道"), visualmap_opts=[ opts.VisualMapOpts(range_color=Faker.visual_color), opts.VisualMapOpts(type_="size", range_size=[10, 50], pos_top="20%"), ], )) return c
def scatter3d_base(f) -> Scatter3D: data = [ [time_m_d(i.now), time_h_m(i.now), i.price] for i in f ] name = ["d", "h", "v"] c = ( Scatter3D(init_opts=opts.InitOpts(theme=ThemeType.LIGHT, width="1366px")) .add("", data, ) .set_global_opts( visualmap_opts=opts.VisualMapOpts(min_=300, max_=1200), title_opts=opts.TitleOpts(title="MC"), toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts()), ) ) return c.render_embed()
def scatter3d_base(): data = [ [random.randint(0, 100), random.randint(0, 100), random.randint(0, 100)] for _ in range(80) ] scatter3d = Scatter3D(init_opts=opts.InitOpts(width="1440px", height="720px")) scatter3d.add( "", data, xaxis3d_opts=opts.Axis3DOpts(type_="value"), yaxis3d_opts=opts.Axis3DOpts(type_="value") ) scatter3d.set_global_opts( visualmap_opts=opts.VisualMapOpts(), title_opts=opts.TitleOpts(title="Scatter3D-基本示例") ) scatter3d.render("./scatter3d_base.html")
def scatter3d_base() -> Scatter3D: # data = [ # [random.randint(0, 100), random.randint(0, 200), random.randint(0, 100)] # for _ in range(10000) # ] data, max_rel = read_as_info( '..\\000LocalData\\as_compare\\as_core_map_data_integrate20191203.csv') c = (Scatter3D(init_opts=opts.InitOpts( width="1080px", height="1080px", page_title="全球互联网网络3D散点图", theme=ThemeType.ROMANTIC)).add( "随机散点", data, grid3d_opts=opts.Grid3DOpts(width=300, height=160, depth=300, rotate_speed=5, is_rotate=True, rotate_sensitivity=2), xaxis3d_opts=opts.Axis3DOpts(type_="value", name="经度", min_=180.0, max_=-180.0), yaxis3d_opts=opts.Axis3DOpts(type_="value", name="维度", min_=-180.0, max_=180.0), zaxis3d_opts=opts.Axis3DOpts(type_="value", name="连通度", min_=0, max_=max_rel + 1), itemstyle_opts=opts.ItemStyleOpts()).set_global_opts( title_opts=opts.TitleOpts("全球互联网网络3D散点图"), visualmap_opts=opts.VisualMapOpts( range_color=Faker.visual_color), )) print(data) print(Faker.visual_color) return c
def draw(): datas = [] import csv with open('guangdong_清洗后-新房.csv', 'r') as f: data = csv.reader(f) pat = re.compile('\d室\d厅') for item in list(data)[1:]: if pat.match(item[5]): p = float(item[-1]) m = float(item[2][:-1]) eq = re.search(pat, item[5]).group() datas.append([eq, p, m]) from pyecharts import options as opts (Scatter3D().add( series_name="", data=datas, xaxis3d_opts=opts.Axis3DOpts(name='配置', type_='category'), yaxis3d_opts=opts.Axis3DOpts(name='价格', ), zaxis3d_opts=opts.Axis3DOpts(name='面积', ), ).render("scatter3d.html"))
data = [] for i in range(len(function1_values)): data.append((f1[i], f2[i], f3[i])) scatter = ( Scatter3D() .add("",data, xaxis3d_opts=opts.Axis3DOpts( name="Fun(1)", type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), yaxis3d_opts=opts.Axis3DOpts( name="Fun(2)", type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), zaxis3d_opts=opts.Axis3DOpts( name="Fun(3)", type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), # grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ) .set_global_opts( title_opts=opts.TitleOpts(title="Best Pareto Scatter"), ) .render(filename) ) os.system(filename) len(data)
data = [int(hi.group(0)), int(lo.group(0))] return data # grap = Line3D() # grap.add('2020',['9','10','11','12'],[1,2,3,6,8]) # grap.show_config() # es = EffectScatter('tu') # es.add_xaxis('xx',['9','10','11','12'],[1,2,3,6,8]) # grap.render() bar = ( Scatter3D(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) # .add_xaxis(["2017", "2018", "2019", "2020"]) # .add_yaxis("10月", [5, 20, 36, 10]) # .add('北京气温',[[2019,10,10],[2020,10,11]],itemstyle_opts=opts.ItemStyleOpts(color='red'),) # .add('北京气温',[[2019,10,3],[2020,10,4]],itemstyle_opts=opts.ItemStyleOpts(color='blue'),) # .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) .set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=20), )) # with open('snoop/weather/cache.html','r') as f: # te = getTemprature(f.read()) # datas[2020] = {10,te} # bar.add('北京气温',[[10,2020,te['low']],[10,2020,te['high']]],itemstyle_opts=opts.ItemStyleOpts(color='red'),) # for y in range(2020,2011-1, -1): # # y = 2019 # for m in range(9,13): # print(f'{y}/{m}') # time.sleep(.2) # url = url_format.replace('%%DATE%%',f'{y}{str(m).zfill(2)}')
Scatter3D( init_opts=opts.InitOpts(width="1440px", height="720px") ) # bg_color="black" .add( series_name="", data=listd, xaxis3d_opts=opts.Axis3DOpts( name=config_xAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), yaxis3d_opts=opts.Axis3DOpts( name=config_yAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), zaxis3d_opts=opts.Axis3DOpts( name=config_zAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ) .set_global_opts( visualmap_opts=[ opts.VisualMapOpts( type_="color", is_calculable=True, dimension=1, pos_top="10", max_=4/2, range_color=[ "#1710c0", "#0b9df0", "#00fea8", "#00ff0d", "#f5f811", "#f09a09", "#fe0300", ], ), opts.VisualMapOpts( type_="size", is_calculable=True, dimension=2, pos_bottom="10", max_=4/2, range_size=[2, 2], ), ] ) .render("E://project/test/3dplot/scatter3d.html")
if tracelistthree not in newtracelist: newtracelist.append(tracelistthree) for j in range(len(newtracelist)): for i in range(len(tracelist)): if newtracelist[j][0] == tracelist[i][1] and newtracelist[j][ 1] == tracelist[i][2] and newtracelist[j][2] == tracelist[i][3]: newtracelist[j].append(tracelist[i][0]) break verden = list(set(verden)) horden = list(set(horden)) newtracelist.insert(0, firstPoint) newtracelist.append(endPoint) print(len(newtracelist)) print(newtracelist) print(horden) print(verden) # 3D散点图 page = Page() # st data = newtracelist range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] scatter3D = Scatter3D() #设置图表的高和宽 scatter3D.add("", data, True, range_color) #视觉映射和颜色选择 page.add(scatter3D) page.render()
import os from pyecharts.charts import Scatter3D import pyecharts.options as opts dir = "/Users/huyelong/Desktop/homework10/data/device_motion/health/female/" for root, dirs, files in os.walk(dir): for file in files: path = os.path.join(root, file) print(path) if path[-5:] == ".json": with open(path, 'r', encoding='utf-8') as f: data = json.load(f) volume = [[i['alpha'], i['beta'], i['gamma']] for i in data] range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] scatter3D = (Scatter3D(init_opts=opts.InitOpts( width="1440px", height="720px")).add( "Sensor Data", volume).set_global_opts( title_opts=opts.TitleOpts(title=file), visualmap_opts=opts.VisualMapOpts( is_show=True, max_=max(i['gamma'] for i in data), min_=min(i['gamma'] for i in data), range_color=range_color)).render(path[:-5] + ".html"))
Scatter3D() # bg_color="black" .add( series_name="", data=data, xaxis3d_opts=opts.Axis3DOpts( name=config_xAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), yaxis3d_opts=opts.Axis3DOpts( name=config_yAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), zaxis3d_opts=opts.Axis3DOpts( name=config_zAxis3D, type_="value", # textstyle_opts=opts.TextStyleOpts(color="#fff"), ), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ).set_global_opts(visualmap_opts=[ opts.VisualMapOpts( type_="color", is_calculable=True, dimension=3, pos_top="10", max_=79 / 2, range_color=[ "#1710c0", "#0b9df0", "#00fea8", "#00ff0d", "#f5f811", "#f09a09", "#fe0300", ], ), opts.VisualMapOpts( type_="size", is_calculable=True, dimension=4, pos_bottom="10", max_=2.4 / 2, range_size=[10, 40], ), ]))
(Scatter3D(init_opts=opts.InitOpts(width="1440px", height="720px")).add( series_name="", data=data, xaxis3d_opts=opts.Axis3DOpts(name=config_xAxis3D, type_="value"), yaxis3d_opts=opts.Axis3DOpts(name=config_yAxis3D, type_="value"), zaxis3d_opts=opts.Axis3DOpts(name=config_zAxis3D, type_="value"), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ).set_global_opts(visualmap_opts=[ opts.VisualMapOpts( type_="color", is_calculable=True, dimension=3, pos_top="10", max_=79 / 2, range_color=[ "#1710c0", "#0b9df0", "#00fea8", "#00ff0d", "#f5f811", "#f09a09", "#fe0300", ], ), opts.VisualMapOpts( type_="size", is_calculable=True, dimension=4, pos_bottom="10", max_=2.4 / 2, range_size=[10, 40], ), ]).render("Scatter3d.html"))
def scatter3d_base() -> Scatter3D: data = [ [random.randint(-10000, 10000), random.randint(-10000, 10000), random.randint(-10000, 10000)] for _ in range(100) ] # 求莫比乌斯环数据 # v_mobius = np.linspace(-1.0, 1.0, num=20, endpoint=True) # u_mobius = np.linspace(0, 2 * np.pi, num=20, endpoint=True) # x_3d = (1. + v_mobius/2. * np.cos(u_mobius/2.)) * np.cos(u_mobius) # print(x_3d) # y_3d = (1. + v_mobius/2. * np.cos(u_mobius/2.)) * np.sin(u_mobius) # print(y_3d) # z_3d = v_mobius/2. * np.sin(v_mobius/2.) # print(z_3d) # data = [[0, 0, 0], [100, 100, 100], [100, -100, -100]] # print(data) # data = [] # temp_list = [] # for iter_cnt in range(0, len(list(x_3d))): # temp_list.append(x_3d[iter_cnt]) # temp_list.append(y_3d[iter_cnt]) # temp_list.append(x_3d[iter_cnt]) # data.append(temp_list) # temp_list = [] print(data) # data, max_rel = read_as_info('..\\000LocalData\\as_compare\\as_core_map_data_integrate20191203.csv') assert isinstance( Scatter3D(init_opts=opts.InitOpts(width="1920px", height="960px", page_title="3D散点图", theme=ThemeType.DARK)) .add("3D散点可视化", data, grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100, rotate_speed=5, is_rotate=False, rotate_sensitivity=2), xaxis3d_opts=opts.Axis3DOpts(type_="value", name="x", textstyle_opts=opts.TextStyleOpts(color="white")), yaxis3d_opts=opts.Axis3DOpts(type_="value", name="y", textstyle_opts=opts.TextStyleOpts(color="white")), zaxis3d_opts=opts.Axis3DOpts(type_="value", name="z", textstyle_opts=opts.TextStyleOpts(color="white")), itemstyle_opts=opts.ItemStyleOpts(color="white", border_width=0.01, border_color="red", area_color="blue"), # label_opts=opts.LabelOpts(color="objectwhite") ) .set_global_opts, ) c = ( Scatter3D(init_opts=opts.InitOpts(width="1920px", height="960px", page_title="3D散点图", theme=ThemeType.DARK)) .add("3D散点可视化", data, grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100, rotate_speed=5, is_rotate=False, rotate_sensitivity=2), xaxis3d_opts=opts.Axis3DOpts(type_="value", name="x", textstyle_opts=opts.TextStyleOpts(color="white")), yaxis3d_opts=opts.Axis3DOpts(type_="value", name="y", textstyle_opts=opts.TextStyleOpts(color="white")), zaxis3d_opts=opts.Axis3DOpts(type_="value", name="z", textstyle_opts=opts.TextStyleOpts(color="white")), itemstyle_opts=opts.ItemStyleOpts(color="white", border_width=0.01, border_color="red", area_color="blue"), # label_opts=opts.LabelOpts(color="white") ) .set_global_opts( title_opts=opts.TitleOpts("3D散点图"), # visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color), ) ) print(data) print(Faker.visual_color) return c