[英]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. 我在python中创建了带注释的热图。 The problem is that the default location for the x axis is at the top not the bottom of the graph.
问题是x轴的默认位置在图形的顶部而不是底部。 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. Plotly的
figurefactory
将返回一个dict
,您可以对其进行修改。 In this case you would set side
of your xaxis
to bottom
. 在这种情况下,您可以将
xaxis
side
设置为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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.