所以我有
hours = [x for x in range(7,18)]
columns = [1, 2, 3, 4, 5]
matrixDatos = [[0,1,0,1,0],
[0,1,0,1,1],
[2,3,2,3,2],
[2,3,2,3,3],
[4,5,4,5,4],
[4,5,4,5,5],
[6,7,6,7,6],
[6,7,6,7,7],
[8,9,8,9,8],
[8,9,8,9,8]
]
table = ff.create_table(matrixDatos)
fig = ff.create_annotated_heatmap(matrixDatos, x=columns, y=hours, colorscale='Viridis')
Run Code Online (Sandbox Code Playgroud)
但是它打印y轴从18到7的热图,是否有办法从7到18打印它?
嗨,我尝试了提供的代码,但收到一个错误消息,说Y轴(小时)数不等于Z轴(matrixDatos)数。因此,为了使代码正常工作,我将范围从7减小到16。
我在布局对象中使用xaxis对象的“ autorange ”参数来反转轴,我们需要使用“ reversed”参数。
hours = [x for x in range(7,17)]
columns = [1, 2, 3, 4, 5]
matrixDatos = [[0,1,0,1,0],
[0,1,0,1,1],
[2,3,2,3,2],
[2,3,2,3,3],
[4,5,4,5,4],
[4,5,4,5,5],
[6,7,6,7,6],
[6,7,6,7,7],
[8,9,8,9,8],
[8,9,8,9,8]
]
table = ff.create_table(matrixDatos)
fig = ff.create_annotated_heatmap(matrixDatos, x=columns, y=hours, colorscale='Viridis')
fig['layout']['yaxis']['autorange'] = "reversed"
iplot(fig)
Run Code Online (Sandbox Code Playgroud)
我希望这是您所需要的。
参考文献:
| 归档时间: |
|
| 查看次数: |
1317 次 |
| 最近记录: |