kurtosis
kurtosis

Reputation: 1405

Additional keyword arguments in seaborn jointplot

I'm trying to find out how matplotlib and seaborn plotting functions are associated. Particularly, I'd like to know what pyplot arguments can be passed into keyword dicts marginal_kws and annot_kws in function seaborn.jointplot().

Suppose we have DataFrame data with columns c0 and c1. I guessed that joint_kws accepts arguments from pyplot.hexbin(), so when I tried to tune the appearance with arguments from there, it worked fine:

import seaborn as sns   
sns.jointplot('c0', 'c1', data=data,  kind='hex',
               joint_kws={'gridsize':100, 'bins':'log', 'xscale':'log', 'yscale':'log'})

Then I tried to set log scale at histogram axes with an argument log=True from pyplot.hist():

    sns.jointplot('c0', 'c1', data=data,  kind='hex',
                   joint_kws={'gridsize':100, 'bins':'log', 'xscale':'log', 'yscale':'log'}, 
                   marginal_kws={'log':True})

This results in

TypeError: distplot() got an unexpected keyword argument 'log'

How to put it right?

P.S. This question is not about setting log scales in seaborn (with JointGrid, i know), but rather about passing matplotlib arguments into seaborn functions as a whole.

Upvotes: 10

Views: 13140

Answers (1)

mwaskom
mwaskom

Reputation: 48992

The dictionary of keyword arguments gets passed to distplot, which takes a dictionary for hist_kws. So you'll have to do something like marginal_kws={'hist_kws': {'log': True}}. With that said, shared log axes remain an enduring headache with jointplot, and I couldn't get something that looked good out of the box when adapting your code. Some tweaking might get it working, though.

It may also be useful to try and use JointGrid directly to avoid this kind of complexity.

Upvotes: 8

Related Questions