Search code examples
pythonplotlyheatmapcolorbar

Plotly Python heatmap colorbar orientation


Is there a way to change the orientation of the colorbar in Plotly heatmap? Setting the orientation in the layout does not do anything:

go.Layout(
    legend=dict(
    orientation="h")
)

It doesn't even give me an error message. I have also tried change the orientation in the colorbar directly:

colorbar = dict(
    orientation="h"
                   )

but I get the error message that 'orientation' is not a valid property of 'plotly.graph_objs.heatmap.ColorBar'.

I know how to set the position of the colorbar and I have looked the valid properties of the colorbar but could not find a way to set its orientation. Is this possible?


Solution

  • I don't believe so. According to this open issue and the response from Chriddyp (co-founder of Plotly), a horizontal colorbar has not been implemented but this feature may be added in future releases of Plotly.

    If you really need it— I suppose you can try to draw the colorbar yourself using annotations but that's admittedly a lot of work.