Sure.
df = pd.DataFrame([[1, 2, 3], [8, 6, 5], [10, 1, 3]])
df = df.rename(columns = {0:'positive', 1:'negative', 2:'neutral'})
df.index = ['a', 'b', 'c']
cm = ['Greens', 'YlOrRd', 'Blues']
fig = make_subplots(rows=1, cols=3, horizontal_spacing=0.0, shared_yaxes=True)
fig.update_yaxes(autorange = 'reversed')
fig.update_xaxes(side = 'top')
tmp = df[['positive']]
fig1 = ff.create_annotated_heatmap(tmp.values,
x=tmp.columns.tolist(),
y=tmp.index.tolist(),
colorscale=cm[0], showscale=False, reversescale=False, opacity=0.75)
tmp = df[['negative']]
fig2 = ff.create_annotated_heatmap(tmp.values,
x=tmp.columns.tolist(),
y=tmp.index.tolist(),
colorscale=cm[1], showscale=False, reversescale=False, opacity=0.75)
tmp = df[['neutral']]
fig3 = ff.create_annotated_heatmap(tmp.values,
x=tmp.columns.tolist(),
y=tmp.index.tolist(),
colorscale=cm[2], showscale=False, reversescale=False, opacity=0.75)
fig.add_trace(fig1.data[0], 1, 1)
fig.add_trace(fig2.data[0], 1, 2)
fig.add_trace(fig3.data[0], 1, 3)
annot1 = list(fig1.layout.annotations)
annot2 = list(fig2.layout.annotations)
annot3 = list(fig3.layout.annotations)
for k in range(len(n)):
annot1[k]['xref'] = 'x1'
annot1[k]['yref'] = 'y1'
for k in range(len(annot2)):
annot2[k]['xref'] = 'x2'
annot2[k]['yref'] = 'y2'
for k in range(len(annot3)):
annot3[k]['xref'] = 'x3'
annot3[k]['yref'] = 'y3'
fig.layout.update(annotations=annot1+annot2+annot3)
fig.show()
I actually managed to reverse the y axis so that part of the question is solved.
Thank you.
EDIT: edited the code
EDIT 2: I tried my code on real data and came across the following problem. One of the rows have significantly higher values, that the others, so the colouring looks funny: one row is brightly coloured, the others are almost white. I will consider switching to imshow() if its an easy fix with the new way.