【问题标题】:Clumped scattered data points due to 1e8 notation in seaborn [duplicate]由于 seaborn 中的 1e8 符号导致聚集的分散数据点 [重复]
【发布时间】:2021-08-11 04:53:22
【问题描述】:

我有一系列类似的值,有 80 个条目。

Index      Value
35        100000
77      20000000
94         83400
153     12700000
189        82600
          ...   
7118      132050
7200        1800
7240      257710
7409    40000000
7736     1000000

当我根据分类变量绘制它时,它会生成这个 1e8 符号并将我的大部分值压缩在 0.0 y 刻度标签周围。

我的代码:

f,ax=plt.subplots(figsize=(12,8))
ax=sb.swarmplot(x=df['col1'], y=df['col2'], data=df)

我怎么能没有这个 1e8 符号并散布我的散点,它们可以被独特地可视化?

更新:我包含 ax.set(yscale="log") 并编辑了 y_tick_labels,它看起来更好。谢谢大家。

ax.set(yscale="log")
ax.set_yticklabels(['100','1000','10000','100,000','1,000,000','10mil','100mil'])

【问题讨论】:

  • 对你有用吗?

标签: python pandas seaborn


【解决方案1】:

考虑为您的绘图使用对数刻度:

plt.xscale('log')

更多详情请见matplotlib documentation

或者在seaborn:

f,ax=plt.subplots(figsize=(12,8))
ax.set(xscale="log")
ax=sb.swarmplot(x=df['col1'], y=df['col2'], data=df)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 2021-06-26
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多