Julius
Julius

Reputation: 49

Reverse range colorscale plotly

I was wondering if it is possible to make my colorscale bar ascending (from 1 to 4) instead of descending (from 4 to 1). Does anyone have clue? The picture of my current bar is underneath the code.

import pandas as pd
import plotly.graph_objects as go
fig = go.Figure(go.Densitymapbox(lat=df_dropped.latitude, lon=df_dropped.longitude, z=df_dropped.propextent,
                                 radius=10))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

enter image description here

Upvotes: 0

Views: 672

Answers (1)

atharva
atharva

Reputation: 90

Just add reversescale=True as below:

import pandas as pd
import plotly.graph_objects as go
fig = go.Figure(go.Densitymapbox(lat=df_dropped.latitude,
lon=df_dropped.longitude, z=df_dropped.propextent,radius=10,reversescale=True
))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

For more details, please visit the reversescale section in the documentation

Upvotes: 1

Related Questions