import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-2, 2, 1000)
y1 = 2 ** x
y2 = 0.1 * 2 ** x
plt.plot(x, y1, label='y=2^x')
plt.plot(x, y2, label='y=0.1*2^x')
plt.xlabel('x')
plt.ylabel('y')
plt.title('y=2^x and y=0.1*2^x in [-2, 2]')
plt.grid(alpha=0.5, linestyle='--')
plt.legend()
plt.show()
python 绘制y=2^x 和 y=0.1*2^x 在定义域为[-2,2]的曲线 并绘制灰色半透明刻度线 刻度线的间隔为0.1
标签:plt,0.1,刻度,y1,y2,绘制 From: https://blog.51cto.com/u_16055028/7715749