Matplotlib inline Python 2.7%

I am trying to run the following code, but I keep getting a syntax error. It sometimes works on an iPython laptop, but it is unstable.

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

%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']);
+4
source share
1 answer

%matplotlib inline is an IPython-specific directive that causes IPython to display matplotlib graphics in a laptop cell, and not 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 a graph.
  • Note that semicolons are not needed at the end of instructions.
+8
source

All Articles