文章目录
-
- x轴对数坐标
- y轴对数坐标
- 均采用对数坐标
- 设置坐标轴刻度、范围
- 用linspace生成数据
x轴对数坐标
x=[1e-11,1e-9,1e-7,1e-6,1e-5]
y=[1,2,3,4,5]
plt.semilogx(x,y,linewidth =1.5, color='green', linestyle='dotted',label='test',alpha=0.7,marker='o')
plt.legend()
plt.show()
y轴对数坐标
y=[1e-11,1e-9,1e-7,1e-6,1e-5]
x=[1,2,3,4,5]
plt.semilogy(x,y,linewidth =1.5, color='red', linestyle='dotted',label='test',alpha=0.7,marker='o')
plt.legend()
plt.show()
均采用对数坐标
y=[1e-11,1e-9,1e-7,1e-6,1e-5]
x=[1e-2,2e-3,3e-4,4e-5,5e-6]
plt.loglog(x,y,linewidth =1.5, color='red', linestyle='dotted',label='test',alpha=0.7,marker='o')
plt.legend()
plt.show()
设置坐标轴刻度、范围
x = np.linspace(-5, 5, 100)
y1 = np.sin(x)
y2 = np.cos(x)
plt.figure(num=3, figsize=(8, 5))
plt.plot(x, y1)
plt.plot(x, y2, color='blue', linewidth=5.0, linestyle='--')
plt.xlim((-5, 5))
plt.ylim((-2, 2))
plt.xlabel('xxxxxxxxxxx')
plt.ylabel('yyyyyyyyyyy')
my_x_ticks = np.arange(-5, 5, 0.5)
my_y_ticks = np.arange(-2, 2, 0.3)
plt.xticks(my_x_ticks)
plt.yticks(my_y_ticks)
plt.show()
用linspace生成数据
a=popt[0]
b=popt[-1]
def f(x):
return a*np.log10(x)+b
x_data=np.linspace(1e3,1e7,100000)
y_data=f(x_data)