import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3,3,50) #设置横轴的取值点
y1 = 2 * x + 1
#曲线1
y2 = x**2
#曲线2
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color='red',linewidth=1,linestyle='--')
plt.show()
plt.figure(num=3,figsize=(8,5))
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3,3,50)
y1 = 2 * x + 1
y2 = x**2
# plt.figure(num=1)
# plt.plot(x,y1)
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color='red',linewidth=1,linestyle='--')
plt.xlim((-1,2))
plt.ylim((-1,2))
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3,3,50)
y1 = 2 * x + 1
y2 = x**2
# plt.figure(num=1)
# plt.plot(x,y1)
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color='red',linewidth=1,linestyle='--')
plt.xlim((-1,2))
plt.ylim((-1,2))
plt.xlabel('XXX')
plt.ylabel('YYY')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3,3,50)
y1 = 2 * x + 1
y2 = x**2
# plt.figure(num=1)
# plt.plot(x,y1)
plt.figure(num=3,figsize=(8,5))
plt.plot(x,y2)
plt.plot(x,y1,color='red',linewidth=1,linestyle='--')
plt.xlim((-1,2))
plt.ylim((-1,2))
plt.xlabel('XXX')
plt.ylabel('YYY')
#
new_ticks = np.linspace(-1,2,10)
print(new_ticks)
plt.xticks(new_ticks)
plt.yticks([-2,-1.8,-1,1.22,3],['really bad','bad','normal','good','really good'])
plt.show()