Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Overlap of x-axis label and figure title

I am trying to create an annotated heatmap:

import plotly.figure_factory as ff
from plotly.offline import plot, iplot

z = [[9, 36 ],[401, 4]]
x = [0,1]
y = [1, 0]

fig = ff.create_annotated_heatmap(z, showscale=True, x = x, y = y)
fig['layout']['title'] = 'Confusion Matrix'
fig['layout']['xaxis']['title'] = 'Predicted label'
fig['layout']['yaxis']['title'] = 'True label'

plotly.offline.plot(fig)

Hovever, my x-axis label and the title are overlapping. Moreover, I want the x-axis label to appear at the bottom and not at the top. Any idea how to do it?

Setting https://plot.ly/javascript/reference/#layout-xaxis-side to ‘bottom’ should do that

Axis title don’t automatically push extra room in the margins for the graph title unfortunately at the moment. So you’ll have to bump the top margin manually https://plot.ly/javascript/reference/#layout-margin-t