反向范围色标图

Reverse range colorscale plotly

我想知道是否可以使我的色阶条上升(从 1 到 4)而不是下降(从 4 到 1)。有人知道吗?我当前栏的图片在代码下方。

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()

只需添加 reversescale=True 如下:

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()

有关详细信息,请访问 documentation

中的 reversescale 部分