songdg
2018-10-24 10:30:39 +08:00
这是书上的一个例子,我发现不用 plt.show()就能显示,但是 plt.legend(loc=(0.64,0.1))就显示上面的提示。
import matplotlib.pyplot as plt
d = [11,12,13,14,15,16,17]
t0 = [15.3,12.6,12.7,13.2,12.3,11.4,12.8]
t1 = [26.1,26.2,24.3,25.1,26.7,27.8,26.9]
t2 = [22.3,20.6,19.8,21.6,21.3,19.4,21.4]
plt.plot(d,t0,label='Tokyo')
plt.plot(d,t1,label='Hawaii')
plt.plot(d,t2,label='Hong Kong')
plt.xlim(11,15)
plt.ylim(0,30)
plt.xlabel('Date',size=12,fontweight='semibold')
plt.ylabel('Temperature (°C)',size=12,fontweight='semibold')
plt.grid(True,linewidth=0.5,color='#aaaaaa',linestyle='-')
plt.title("Daily temperature of 3 cities in the second week of December", size=14, fontweight='bold')
plt.legend(loc=(0.64,0.1))
plt.show()