如何使x轴标签显示在带注释的热图python的底部而不是顶部? [英] How to make x axis label show up at the bottom not the top in Annotated Heatmap plotly python?

查看:542
本文介绍了如何使x轴标签显示在带注释的热图python的底部而不是顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created a annotated heatmap in plotly python. The problem is that the default location for the x axis is at the top not the bottom of the graph. I have been searching the reference page and cannot figure out how to configure this. The default for a regular heatmap is at the bottom but the annotated heatmap version default is at the top.

推荐答案

Plotly的figurefactory返回一个您可以修改的dict ionary.在这种情况下,您可以将xaxis side 设置为bottom.

Plotly's figurefactory returns a dictionary which you can modify. In this case you would set side of your xaxis to 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)

这篇关于如何使x轴标签显示在带注释的热图python的底部而不是顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆