簡體   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