我正在尝试找出matplotlib和seaborn绘图函数是如何关联的。特别是,我想知道哪些pyplot参数可以传递给seaborn.jointplot()函数中的关键字dicts marginal_kws和annot_kws。
假设我们有包含列c0和c1的DataFrame data。我猜想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函数中。
发布于 2014-10-16 09:41:34
关键字参数的字典被传递给distplot,它接受hist_kws的字典。所以你必须做一些像marginal_kws={'hist_kws': {'log': True}}这样的事情。尽管如此,共享日志轴仍然是jointplot的一个令人头疼的问题,我无法在修改代码时获得开箱即用的好东西。不过,一些调整可能会让它正常工作。
尝试使用JointGrid directly来避免这种复杂性可能也很有用。
https://stackoverflow.com/questions/26357363
复制相似问题