Manuel
Manuel

Reputation: 41

matplotlib inline Python 2.7 %

I'm trying to run the following code, but I keep getting a Syntax Error. It runs sometimes on iPython notebook, but it's not stable.

The code is supposed to get a bubble chart of the variables set.

%matplotlib inline

import pandas as pd
import numpy as np

df = pd.read_csv('effort.csv')
df.plot(kind='scatter', x='setting', y='effort', s=df['country']*df['change']);

Upvotes: 4

Views: 8619

Answers (1)

unutbu
unutbu

Reputation: 879083

%matplotlib inline is an IPython-specific directive which causes IPython to display matplotlib plots in a notebook cell rather than in another window.

To run the code as a script use

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

df = pd.read_csv('effort.csv')
df.plot(kind='scatter', x='setting', y='effort', s=df['country']*df['change'])
plt.show()

  • Use plt.show() to display the plot
  • Note that semicolons are not necessary at the end of statements.

Upvotes: 10

Related Questions