4

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']);

1 Answer 1

10

%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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.