Maxi
Maxi

Reputation: 557

Python pandas : pd.options.display.mpl_style = 'default' causes graph crash

Everything is in the title. My graph is displayed properly when I do not set this option at the beginning of my python script, otherwise it opens the window for the graph but closes it straightback and end the run.

I am using pandas 0.14.0 and matplotlib 1.3.0.

Anyone already saw this ? You can see my code below if needed.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#pd.options.display.mpl_style = 'default'

df = pd.DataFrame(np.random.randn(1000, 4), index=pd.date_range('1/1/2000',periods=1000), columns=list('ABCD'))
df = df.cumsum()
df.plot(legend=False)

plt.show()

Upvotes: 10

Views: 9167

Answers (2)

johnml1135
johnml1135

Reputation: 4987

I was experiencing a similar error with Matplotlib v1.4. The solution I found is to use

matplotlib.style.use('ggplot')

rather than

pd.options.display.mpl_style = 'default'

See - https://pandas-docs.github.io/pandas-docs-travis/visualization.html

Upvotes: 12

rmalhotra
rmalhotra

Reputation: 155

Use the following:

plt.show(block=True)

Upvotes: 9

Related Questions