Python 3.x 有没有办法在plotly的热图中反转y轴的顺序
所以我有Python 3.x 有没有办法在plotly的热图中反转y轴的顺序,python-3.x,plotly,Python 3.x,Plotly,所以我有 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
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')
但是它用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)
代码更改输出:
我希望这就是你需要的
参考资料: