2

Function of pandas.scatter_matrix stopped to work well in Jupyter Notebook.

All the time it drew this plot:

enter image description here

And now it shows this way:

enter image description here

And I can't figure out, what affected this.

What can be the reason?

UPDATE

Looks like usage of seaborn heatmap in previous cells damages the function.

How to recover from seaborn.heatmap?

UPDATE 2

matplotlib.style.use('classic')

didn't recover completely

enter image description here

UPDATE 3

The following command

plt.rcParams.update(plt.rcParamsDefault)

also recovers only partially.

Dims
  • 47,675
  • 117
  • 331
  • 600
  • 1
    this usually happens after the `import seaborn` command, but `matplotlib.style.use('ggplot')` gives you the same or very similar effect, so try to play with `matplotlib.style.use(...)` – MaxU - stand with Ukraine Jan 11 '17 at 18:58

1 Answers1

2

UPDATE:

As stated in this great answer:

%matplotlib inline uses its own rcParams. You can grab that from the source, but the arguably easier way is probably just save the rcParams as inline_rc after %matplotlib inline cell magic in this example, and reuse that later.

saved_plt_params = plt.rcParams  # call it before `import seaborn` !
import seaborn
...
plt.rcParams = saved_plt_params

OLD answer:

This should "fix" the style:

matplotlib.style.use('classic')

NOTE: you may want to read about matplotlib styles

DEMO:

In [4]: s = pd.Series(np.random.randn(100)).add(.1).cumsum()

In [5]: %matplotlib
Using matplotlib backend: Qt5Agg

In [6]: s.plot()
Out[6]: <matplotlib.axes._subplots.AxesSubplot at 0xbe16d68>

enter image description here

after we executed import seaborn:

In [7]: import seaborn

In [8]: s.plot()
Out[8]: <matplotlib.axes._subplots.AxesSubplot at 0xf4782e8>

enter image description here

let's "fix" it:

In [10]: plt.style.use('classic')

In [11]: s.plot()
Out[11]: <matplotlib.axes._subplots.AxesSubplot at 0xf6e3cc0>

enter image description here

Community
  • 1
  • 1
MaxU - stand with Ukraine
  • 205,989
  • 36
  • 386
  • 419