0

Is there a possibilty in Plotly Express to set the color scale horizontal under the graph. Here is my code:

import plotly.express as px
fig = px.scatter(df, x="year", y="Temperature", trendline="ols",
                 color="Temperature", color_continuous_scale=px.colors.sequential.Hot_r)

I tried: fig.update_coloraxes(colorbar_orientation="h") but just get an error.

saibot_90
  • 39
  • 6
  • Earlier versions had errors, but the latest version (5.5.0) has been improved. What version are you currently using? If it is old, I would recommend upgrading. – r-beginners Jan 13 '22 at 12:18
  • I use the newest version 5.5 but get this error: ValueError: Invalid property specified for object of type plotly.graph_objs.layout.coloraxis.ColorBar: 'orientation' Did you mean "bordercolor"?....Et cetera – saibot_90 Jan 13 '22 at 12:24
  • In the colab it seems fine, i use pycharm and streamlit to show my plot but even with copying your code i get an error – saibot_90 Jan 13 '22 at 12:53
  • That's about all I can help you with, I'll disable Colab. I don't know why the error message is showing graph_objects. – r-beginners Jan 13 '22 at 13:01

1 Answers1

2

You just need to add:

fig.update_layout(coloraxis=dict(colorbar=dict(orientation='h', y=-0.15)))