【问题标题】:Reverse range colorscale plotly反向范围色标绘图
【发布时间】:2021-08-29 13:31:19
【问题描述】:

我想知道是否可以让我的色标条上升(从 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()

【问题讨论】:

    标签: graph plotly


    【解决方案1】:

    只需添加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部分

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-10
      • 2015-08-02
      • 1970-01-01
      • 2017-09-15
      • 2019-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多