使用的软件为jupyter,python3
已经使用legend()但结果仍然不对
import matplotlib.pyplot as plt
x=range(60)
y=[random.uniform(15,18) for i in x]
yshang=[random.uniform(1,3) for i in x]
plt.figure(figsize=(30,30),dpi=80)
plt.plot(x,y,color="r")
plt.plot(x,yshang,color="b",linestyle='-.')
plt.yticks(range(0,40,5))
plt.xlabel("shijian")
plt.legend()
plt.show()
结果
TypeError Traceback (most recent call last)
C:\Users\XUHONG~1\AppData\Local\Temp/ipykernel_29504/3528747620.py in <module>
8 plt.plot(x,yshang,color="b",linestyle='-.')
9 plt.yticks(range(0,40,5))
---> 10 plt.xlabel("shijian")
11 plt.legend()
12 plt.show()
TypeError: 'str' object is not callable