David Parks
David Parks

Reputation: 32111

matplotlib changed rendering style unexpectedly in jupyter-notebook

My matplotlib plots have changed styles unexpectedly. I am trying to pin down what I did to change them. My best guess is that I changed matplotlib versions, or I'm possibly am using a different backend.

A histogram plot currently looks like this:

Current plot style

They used to look like this (nice defined border lines between the bars):

enter image description here

I have made no changes to the code that generates the plots, but I have mucked with import statements, and re-installed various components of anaconda, including matplotlib for unrelated reasons.

Upvotes: 0

Views: 541

Answers (2)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339590

Starting from matplotlib version 2.0, patches do not have edges anymore. See the Changes to the default style.

Options to set edges back on:

  1. Use the edgecolor argument of the artist. E.g.

    plt.bar(...., edgecolor="k")
    
  2. Use the rcParams to globally set edges,

    plt.rcParams['patch.force_edgecolor'] = True
    

    or edit you matplotlibrc file accordingly.

  3. Turn the old style on again, using

    plt.style.use('classic')
    

Upvotes: 1

Demetri Pananos
Demetri Pananos

Reputation: 7404

Earlier this year, matplotlib changed their defaults. You want the edgecolor param.

plt.hist(np.random.norma(0,1,100), edgecolor='k')

enter image description here

You can use a classic style by passing plt.style.use('classic').

Upvotes: 1

Related Questions