Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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']);
like image 509
Manuel Avatar asked Dec 24 '22 08:12

Manuel


1 Answers

%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.
like image 134
unutbu Avatar answered Dec 28 '22 22:12

unutbu