def surface3d_base() -> Surface3D: def surface3d_data(): for t0 in range(-60, 60, 1): y = t0 / 60 for t1 in range(-60, 60, 1): x = t1 / 60 if math.fabs(x) < 0.1 and math.fabs(y) < 0.1: z = "-" else: z = math.sin(x * math.pi) * math.sin(y * math.pi) yield [x, y, z] c = (Surface3D().add( "", list(surface3d_data()), xaxis3d_opts=opts.Axis3DOpts(type_="value"), yaxis3d_opts=opts.Axis3DOpts(type_="value"), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ).set_global_opts( title_opts=opts.TitleOpts(title="Surface3D-基本示例"), visualmap_opts=opts.VisualMapOpts(max_=3, min_=-3, range_color=Faker.visual_color), )) return c
def surface3D_flower() -> Surface3D: def surface3d_data(): for t0 in range(-30, 30, 1): y = t0 / 10 for t1 in range(-30, 30, 1): x = t1 / 10 z = math.sin(x * x + y * y) * x / 3.14 yield [x, y, z] c = ( Surface3D() .add( "", list(surface3d_data()), xaxis3d_opts=opts.Axis3DOpts(type_="value"), yaxis3d_opts=opts.Axis3DOpts(type_="value"), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ) .set_global_opts( title_opts=opts.TitleOpts(title="Surface3D-曲面波图"), visualmap_opts=opts.VisualMapOpts( max_=1, min_=-1, range_color=Faker.visual_color ), ) ) return c
def test_surface3d_base(): def surface3d_data(): for t0 in range(-60, 60, 1): y = t0 / 60 for t1 in range(-60, 60, 1): x = t1 / 60 if math.fabs(x) < 0.1 and math.fabs(y) < 0.1: z = "-" else: z = math.sin(x * math.pi) * math.sin(y * math.pi) yield [x, y, z] c = (Surface3D().add( "", list(surface3d_data()), xaxis3d_opts=opts.Axis3DOpts(type_="value"), yaxis3d_opts=opts.Axis3DOpts(type_="value"), grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100), ).set_global_opts(visualmap_opts=opts.VisualMapOpts( max_=3, min_=-3, range_color=Faker.visual_color))) eq_(c.theme, "white") eq_(c.renderer, "canvas") c.render()
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", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf", "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026", ], ) ) .render("surface_wave.html")
# print(l) # ''' c = ( Surface3D().add( series_name="", shading="color", # data=list(zip(*x,*y,*z)), data=l, 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", # "#4575b4", # "#74add1", # "#abd9e9", # "#e0f3f8", # "#ffffbf", # "#fee090", # "#fdae61", # "#f46d43", # "#d73027", # "#a50026", # ], ))) c.width = "100%" put_html(c.render_notebook())
def __init__(self): self.data_set = [] self.gragh = Surface3D()
Surface3D(init_opts=opts.InitOpts()) .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=80, depth=100), ) .set_global_opts( visualmap_opts=opts.VisualMapOpts( dimension=2, max_=1, min_=-1, range_color=[ "#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf", "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026", ], ), title_opts=opts.TitleOpts(title="养老业与经济发展模拟图", pos_left='38%', pos_top='10%') ) .render_notebook()
def plot_performance_overview(dict_results, plot_tymod, p): if plot_tymod == "pic": figs = {} for k, v in dict_results.items(): v = v.unstack() series = v.index.get_level_values(0).unique() if isinstance( v.index, pd.MultiIndex) else [k] c = 3 r = np.ceil(len(series) / c) fig = plt.figure(figsize=(8, 6)) plt.subplots_adjust(hspace=0.3) for i, _s in enumerate(series): _data = v.loc[_s] if isinstance(v.index, pd.MultiIndex) else v X, Y = np.meshgrid(_data.index, _data.columns, indexing='ij') Z = _data.values pos = int(r * 100 + c * 10 + (i + 1)) ax = fig.add_subplot(pos, projection='3d') ax.plot_surface(X, Y, Z, color='b') ax.set_title("%s" % _s, fontdict={"size": 8}) figs[k] = fig fig.savefig("%s_%s.png" % (p, k)) return figs elif plot_tymod == 'dyn-3d': results = {} for k, perf in dict_results.items(): perf = perf.unstack() c = (Surface3D(init_opts=opts.InitOpts( width="1000px", height="500px")).set_global_opts( title_opts=opts.TitleOpts(title="绩效-曲面波图(%s)" % k), visualmap_opts=opts.VisualMapOpts( max_=perf.values.max(), min_=perf.values.min(), range_color=Faker.visual_color), toolbox_opts=opts.ToolboxOpts(is_show=True), )) series = perf.index.get_level_values(0).unique() if isinstance( perf.index, pd.MultiIndex) else [k] for i, _s in enumerate(series): _data = perf.loc[_s] if isinstance(perf.index, pd.MultiIndex) else perf X, Y = np.meshgrid(_data.index, _data.columns) d = list( zip(X.flatten().astype(str), Y.flatten().astype(str), _data.values.T.flatten().astype(np.float))) c = c.add( series_name=str(_s), shading="color", data=d, xaxis3d_opts=opts.Axis3DOpts(type_="category"), yaxis3d_opts=opts.Axis3DOpts(type_="category"), grid3d_opts=opts.Grid3DOpts(width=100, height=50, depth=100), ) results[k] = c tab = Tab() for k, v in results.items(): tab.add(v, k) tab.render("%s.html" % p) elif plot_tymod == "dyn-hm": tab = Tab() for k, v in dict_results.items(): v = v.unstack() _tl = _timeline(v, name=k) tab.add(_tl, k) tab.render("%s.html" % p)
x = t1 z = range_data[y, x] yield [x, y, z] (Surface3D(init_opts=opts.InitOpts(width="1600px", height="800px")).add( series_name="", shading="color", data=list(surface3d_data(range_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_=50, min_=40, range_color=[ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026', ], )).render("surface_wave.html"))