【发布时间】:2020-06-16 10:30:36
【问题描述】:
我在 Jupyter 中有以下代码,目前正在遵循 DataCamp 上的教程,但是我的绘图没有生成。
import matplotlib as mpl
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.show()
seattle_weather_dic = {'MONTH':['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
'MLY-TAVG-NORMAL':[42.1,43.4,46.6,50.5,56.0,61.0,65.9,66.5,61.6,53.3,46.2,41.1]}
seattle_weather = pd.DataFrame.from_dict(seattle_weather_dic)
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"])
plt.show()
【问题讨论】:
-
我觉得
:后面应该有'MONTH' -
另外,未定义 ax。当你运行这段代码时你看到了什么?
-
道歉,:在原始代码中包含“MONTH”之后。这里弄错了。运行代码时我没有收到任何错误
-
尝试在笔记本开头添加 %matplotlib inline
标签: python pandas matplotlib jupyter