【发布时间】:2014-12-09 01:02:39
【问题描述】:
我试图找出 matplotlib 和 seaborn 绘图函数是如何关联的。特别是,我想知道哪些 pyplot 参数可以传递到函数seaborn.jointplot() 中的关键字字典marginal_kws 和annot_kws。
假设我们有 DataFrame data,列有 c0 和 c1。我猜想joint_kws 接受来自pyplot.hexbin() 的参数,所以当我尝试用那里的参数调整外观时,它工作正常:
import seaborn as sns
sns.jointplot('c0', 'c1', data=data, kind='hex',
joint_kws={'gridsize':100, 'bins':'log', 'xscale':'log', 'yscale':'log'})
然后我尝试使用来自pyplot.hist() 的参数log=True 在直方图轴上设置对数比例:
sns.jointplot('c0', 'c1', data=data, kind='hex',
joint_kws={'gridsize':100, 'bins':'log', 'xscale':'log', 'yscale':'log'},
marginal_kws={'log':True})
这会导致
TypeError: distplot() got an unexpected keyword argument 'log'
如何正确表达?
附:这个问题不是关于在 seaborn 中设置对数比例(我知道 JointGrid),而是关于将 matplotlib 参数作为一个整体传递给 seaborn 函数。
【问题讨论】:
-
我可以看到您使用的是
jointplot,但为什么distplot会出现错误? -
我没有深入研究源代码,但我认为
jointplot边缘的直方图是通过distplot构造的。我还以为marginal_kws对应distplot中的{hist, kde, rug, fit}_kws,但好像不正确。
标签: python matplotlib seaborn