多曲面图,包括 Plotly 中的布局?
Multiple Surface Plot including Layout in Plotly?
Plotly 有一个 Surface Plots (https://plot.ly/python/3d-surface-plots/) 页面,其中有两个很好的示例,第一个使用 Figure 和 Layout 进行绘图。第二个只是使用 iplot() 没有布局修改。但第二个示例演示了如何同时绘制多个曲面。我需要两者:(即我需要调用 fig = go.Figure(data=data, layout=layout)
,就像在第一个实例中一样(因为我需要提供布局设置),但是数据对象包含多个表面。
这似乎没有按预期工作。有什么想法吗?
要定义布局并绘制多个表面,您可以运行像这样:
import plotly.plotly as py
from plotly.graph_objs import Surface
z1 = [
[8.83,8.89,8.81,8.87,8.9,8.87],
[8.89,8.94,8.85,8.94,8.96,8.92],
[8.84,8.9,8.82,8.92,8.93,8.91],
[8.79,8.85,8.79,8.9,8.94,8.92],
[8.79,8.88,8.81,8.9,8.95,8.92],
[8.8,8.82,8.78,8.91,8.94,8.92],
[8.75,8.78,8.77,8.91,8.95,8.92],
[8.8,8.8,8.77,8.91,8.95,8.94],
[8.74,8.81,8.76,8.93,8.98,8.99],
[8.89,8.99,8.92,9.1,9.13,9.11],
[8.97,8.97,8.91,9.09,9.11,9.11],
[9.04,9.08,9.05,9.25,9.28,9.27],
[9,9.01,9,9.2,9.23,9.2],
[8.99,8.99,8.98,9.18,9.2,9.19],
[8.93,8.97,8.97,9.18,9.2,9.18]
]
z2 = [[zij+1 for zij in zi] for zi in z1]
z3 = [[zij-1 for zij in zi] for zi in z1]
data = [
dict(z=z1, type='surface'),
dict(z=z2, showscale=False, opacity=0.9, type='surface'),
dict(z=z3, showscale=False, opacity=0.9, type='surface')]
# Add all layout info here
layout = dict(title = 'Add Layout')
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='multiple-surfaces-add-layout')
Plotly 有一个 Surface Plots (https://plot.ly/python/3d-surface-plots/) 页面,其中有两个很好的示例,第一个使用 Figure 和 Layout 进行绘图。第二个只是使用 iplot() 没有布局修改。但第二个示例演示了如何同时绘制多个曲面。我需要两者:(即我需要调用 fig = go.Figure(data=data, layout=layout)
,就像在第一个实例中一样(因为我需要提供布局设置),但是数据对象包含多个表面。
这似乎没有按预期工作。有什么想法吗?
要定义布局并绘制多个表面,您可以运行像这样:
import plotly.plotly as py
from plotly.graph_objs import Surface
z1 = [
[8.83,8.89,8.81,8.87,8.9,8.87],
[8.89,8.94,8.85,8.94,8.96,8.92],
[8.84,8.9,8.82,8.92,8.93,8.91],
[8.79,8.85,8.79,8.9,8.94,8.92],
[8.79,8.88,8.81,8.9,8.95,8.92],
[8.8,8.82,8.78,8.91,8.94,8.92],
[8.75,8.78,8.77,8.91,8.95,8.92],
[8.8,8.8,8.77,8.91,8.95,8.94],
[8.74,8.81,8.76,8.93,8.98,8.99],
[8.89,8.99,8.92,9.1,9.13,9.11],
[8.97,8.97,8.91,9.09,9.11,9.11],
[9.04,9.08,9.05,9.25,9.28,9.27],
[9,9.01,9,9.2,9.23,9.2],
[8.99,8.99,8.98,9.18,9.2,9.19],
[8.93,8.97,8.97,9.18,9.2,9.18]
]
z2 = [[zij+1 for zij in zi] for zi in z1]
z3 = [[zij-1 for zij in zi] for zi in z1]
data = [
dict(z=z1, type='surface'),
dict(z=z2, showscale=False, opacity=0.9, type='surface'),
dict(z=z3, showscale=False, opacity=0.9, type='surface')]
# Add all layout info here
layout = dict(title = 'Add Layout')
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='multiple-surfaces-add-layout')