繁体   English   中英

如何使X轴标签显示在带注释的热图python的底部而不是顶部?

[英]How to make x axis label show up at the bottom not the top in Annotated Heatmap plotly python?

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

Plotly的figurefactory将返回一个dict ,您可以对其进行修改。 在这种情况下,您可以将xaxis side设置为bottom

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

在此处输入图片说明

例子取自这里

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM