我希望为两个热图子图设置相同的Z轴。
目前,plotly会生成2个独立的刻度并将它们叠加在一起。
目前我所处的位置是这里,但无法将两个比例尺合并...
import plotly.offline as py
import plotly.graph_objs as go
from plotly import tools
fig = tools.make_subplots(rows=1, cols=2, shared_yaxes=True)
# shared_zaxes=True does not exists
data = [
{'x' : [1, 2, 3],
'y' : [1, 2, 3],
'z' : [[2,5,6],[8,7,3],[1,7,3]]
},
{'x' : [1, 2, 3],
'y' : [1, 2, 3],
'z' : [[1,2,3],[2,3,1],[1,2,3]]
}
]
maxValue = 0
for i in [0,1]:
print(i)
trace = go.Heatmap(z=data[i]['z'],
x=data[i]['x'],
y=data[i]['y'],
colorscale='Jet')
fig.append_trace(dict(trace, showscale=True), 1, i+1)
maxValue = max(max(data[i]['z'])) if max(max(data[i]['z'])) > maxValue else maxValue
fig['layout'].update(title='Same Zaxis')
fig['layout']['scene']['zaxis'].update(range=[0,maxValue])
py.plot(fig , filename='sameZaxis-heatmap')