【问题标题】:Set bounds on plotly express choropleth color scale在 plotly express choropleth 色标上设置界限
【发布时间】:2021-06-12 03:54:25
【问题描述】:

我想在 plotly express 中设置等值线图的界限,例如这样这张地图是从 0 到 5 而不是 1 到 100。这可能吗?

import pandas as pd
import plotly.express as px

df = pd.DataFrame({"state": ["CA", "OR"], "val": [1, 100]})

fig = px.choropleth(locations=df.state,
                    locationmode="USA-states",
                    color=df.val,
                    scope="usa")
fig.show()

(notebook)

【问题讨论】:

    标签: python plotly choropleth


    【解决方案1】:

    使用range_color 参数:

    fig = px.choropleth(locations=df.state,
                        locationmode="USA-states",
                        color=df.val,
                        scope="usa",
                        range_color=(0,5))
    fig.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 2019-07-16
      • 2021-12-01
      • 2020-12-04
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      相关资源
      最近更新 更多