如何使x轴标签显示在底部而不是在Annotated Heatmap中的顶部plot python?

时间:2017-03-29 08:09:31

标签: python heatmap plotly

我在plotly python中创建了一个带注释的热图。问题是x轴的默认位置位于图形的顶部而不是底部。我一直在搜索参考页面,无法弄清楚如何配置它。常规热图的默认值位于底部,但带注释的热图版本默认位于顶部。

1 个答案:

答案 0 :(得分:0)

Plotly figurefactory会返回dict离合器,您可以修改它。在这种情况下,您可以将xaxis的{​​{3}}设置为bottom

fig['layout']['xaxis']['side'] = 'bottom'

side

取自enter image description here

的示例
import plotly.figure_factory as ff
import plotly
plotly.offline.init_notebook_mode()

z = [[.1, .3, .5],  
     [1.0, .8, .6],
     [.6, .4, .2]]

x = ['Team A', 'Team B', 'Team C']
y = ['Game Three', 'Game Two', 'Game One']

z_text = [['Win', 'Lose', 'Win'],  
          ['Lose', 'Lose', 'Win'],
          ['Win', 'Win', 'Lose']]

fig = plotly.figure_factory.create_annotated_heatmap(z, 
                                                     x=x, 
                                                     y=y, 
                                                     annotation_text=z_text, 
                                                     colorscale='Viridis')
fig['layout']['xaxis']['side'] = 'bottom'
plotly.offline.iplot(fig)