【发布时间】:2019-10-24 18:05:47
【问题描述】:
我正在尝试在 python 中使用 seaborn 创建一个 kde 图,但是在将颜色条值设置为以科学记数法显示时,我看不出有什么区别。
请参阅 - making colorbar with scientific notation in seaborn 了解相关主题。
有关 seaborn 的 kde 类的文档,请参阅 - https://seaborn.pydata.org/generated/seaborn.kdeplot.html。
是否有某些原因导致这对 kde 类不起作用,或者我在格式化时犯了一个愚蠢的错误?
import numpy as np
import seaborn as sns
import matplotlib.ticker as tkr
a = np.random.normal(0,1,size=100)
b = np.random.normal(0,1,size=100)
fig, ax = plt.figure(), plt.subplot(111)
formatter = tkr.ScalarFormatter(useMathText=True)
formatter.set_scientific(True)
sns.kdeplot(a,b, n_levels=10, shade=True, cmap='Blues',
cbar=True, cbar_kws={'format':formatter})
结果:
在这里,我希望颜色条显示索引符号,如该问题描述中的第一个链接中所示。
非常感谢!
【问题讨论】:
标签: python seaborn colorbar scientific-notation