'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 1:[1]

Set the orientation of the colorbar.

As per the Plotly Documentation:

# For the vertical orintation
fig.update_traces(colorbar_orientation='v', selector=dict(type='heatmap'))

# For the horizontal orintation
fig.update_traces(colorbar_orientation='h', selector=dict(type='heatmap'))

Default: "v" #vertical

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NILESH KUMAR