Reputation: 85
I've got the following code in Jupyter , curretly following a tutorial on DataCamp, however my plot is not getting generated.
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()
Upvotes: 0
Views: 197
Reputation: 655
Try this:
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
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)
fig,ax=plt.subplots()
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"])
plt.show()
I have defined ax
and added a :
after 'MONTH'
.
Upvotes: 1