我正在试图启动一个IPython笔记本中找到的代码(我还添加了一些代码,比如:interactive(True)...),但当我在Idle中使用“run module”时,它会启动“data.plot”,然后加载但什么也不发生。data.plot似乎无法工作。谢谢,如果您有任何想法。注意:如果没有“interactive(True)”,会弹出一个带有“Runtime error”的框。
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import interactive
interactive(True)
# read data into a DataFrame
data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0)
print(data.head())
# print the shape of the DataFrame
print data.shape
# visualize the relationship between the features and the response using scatterplots
fig, axs = plt.subplots(1, 3, sharey=True)
data.plot(kind='scatter', x='TV', y='Sales', ax=axs[0], figsize=(16, 8))
data.plot(kind='scatter', x='Radio', y='Sales', ax=axs[1])
data.plot(kind='scatter', x='Newspaper', y='Sales', ax=axs[2])