Why doesn't the height parameter work for sns.FacetGrid on mission 152-9?

The documentation for sns.FacetGrid() shows that a “height” parameter can be set to control the height of the plots, and does not use a “size” parameter:

However, when I tried to set the height parameter in the course, I got the following error:

TypeErrorTraceback (most recent call last)
in ()
----> 1 g = sns.FacetGrid(titanic, row=‘Pclass’, col=‘Survived’, hue=‘Sex’, height=4)
2 g.map(sns.kdeplot, ‘Age’, shade=True)

TypeError: init() got an unexpected keyword argument 'height

Despite there not being any discussion of a “size” parameter in the documentation, the code works when I use “size” instead of “height”. Is this discrepancy mission using an older version of seaborn? This seems like an oversight given that the instructions for the mission direct you to the seaborn documentation, which shows the “height” rather than “size” parameter.

You’re right that this is due to an older version of seaborn. Running the line print(sns.__version__) (since seaborn was already imported as sns) shows that the version on the platform is 0.7.1. The documentation always shows the most recent version, so that’s probably why there seems to be a discrepancy (likely at the time the documentation matched the lesson). The current documentation is for v0.10.0. At the top of the page if you click Site --> Release Notes, it shows you what has changed in each version. Searching the page, it looks like the change from size to height happened with version 0.9.0:

Renamed the size parameter to height in multi-plot grid objects ( FacetGrid , PairGrid , and JointGrid ) along with functions that use them ( factorplot , lmplot() , pairplot() , and jointplot() ) to avoid conflicts with the size parameter that is used in scatterplot and lineplot (necessary to make relplot() work) and also makes the meaning of the parameter a bit more clear.

Sahil wrote up a post here about getting different results outside the platform due to version issues that I think is worth a read.

I agree that it’s frustrating when the documentation doesn’t seem to line up with the lesson though. I had that headache with matplotlib many times when trying to do some personal projects. The one plus I’ve gotten out of it is that once I learned there were some differences between versions, I got better at searching for solutions and reading documentation.

1 Like