Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 226
kurtosis Avatar asked Oct 14 '14 09:10

kurtosis


1 Answers

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.

like image 167
mwaskom Avatar answered Sep 24 '22 05:09

mwaskom