简体   繁体   中英

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

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

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

在此处输入图片说明

Example taken from 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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