7
votes

I just upgraded to IPython Notebook version 3.0 and it's disabling the formatting for seaborn. Here's some sample code that replicates the problem

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline

data = np.random.randn(100)

fig,ax = plt.subplots(figsize = (11,8.5))
ax.plot(data)

This code works just fine in IPython Notebook V2.4.1 (see http://nbviewer.ipython.org/gist/anonymous/71733c24a68ee464ca40), but in IPython Notebook v3.0, the axes become invisible (see http://nbviewer.ipython.org/gist/anonymous/7525146b07709206908c).

Strangely, in V3, when I switch the order of the seaborn import and the matplotlib inline magic, the plot renders normally the first time I run, then if I re-run, the axes and gridlines disappear. So it seems to have something to do with the inline magic disabling seaborn properties.

Any workarounds, other than not re-executing my imports after the first time?

1
It's a known issue: github.com/ipython/ipython/issues/7964. It's not really IPython "disabling" seaborn, but just setting different and conflicting matplotlob parameters for the Axes background. - mwaskom
Typing "seaborn.set_style('darkgrid')" after the inline magic fixes it. Thanks! - ollerend
Thanks @ollerend. That fixed it for me. You may want to make your answer a full reply so that OP can mark it as the correct one. - DrMisha

1 Answers

3
votes

In iPython Notebook 3.0, add:

seaborn.set_style('darkgrid')

to restore Seaborn default color schemes.