【问题标题】:How to Convert Color-Code Legends from Logarithmic Scale to Actual Values?如何将颜色代码图例从对数刻度转换为实际值?
【发布时间】:2020-07-22 15:10:11
【问题描述】:

plotly.figure_factory.create_choropleth 中使用对数刻度颜色编码时,在颜色代码图例中显示actual 值的最佳方式是什么?

这里是示例代码:

import plotly.figure_factory as ff

fips   = df['fips']
values = np.log10(df['values'])
endpts = list(np.linspace(0, 4, len(colorscale) - 1))

fig = ff.create_choropleth(fips=fips, values=values, scope = ['usa'], binning_endpoints = endpts)

这是我目前拥有的:

这是我想要的:

与上图完全相同,只是图例中显示的是实际数字而不是 log10(values)。例如,而不是 0.0-0.5 和 0.5-1.0(意思是 10^0 到 10^1/2 和 10^1/2 到 10^1)我想看到:1-3、4 -10 等等。

【问题讨论】:

  • 你能给我一份 MWE 吗?

标签: python plot colors plotly legend


【解决方案1】:

我不熟悉 Plotly API,并且由于您没有提供最小的工作示例,因此我很难测试,但我非常有信心您可以指定颜色图。如果是这样,那么您可以将颜色图转换为对数比例,同时以线性比例输入数字。

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    • 2023-04-06
    • 2011-04-17
    • 1970-01-01
    相关资源
    最近更新 更多