plt.plot绘图
作者:互联网
由于改变图片大小,导致相应修改刻度尺、线段等信息。
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.plot(x,y,color='red',linewidth=0.5,linestyle='-',marker='.',markeredgecolor='red',markersize=2)
plt.axhline(0,color='k',linewidth=0.4,linestyle='--')
plt.bar(x,y,color='blue')
plt.xlabel('1',fontsize=4)
plt.ylabel('2 ($km^{3}$)',fontsize=4) #注意三次方表示方法
plt.yticks(fontproperties = 'Times New Roman', size = 4)
plt.xticks(fontproperties = 'Times New Roman', size = 4)
bwith = 0.4 #边框宽度设置为2
ax = plt.gca()#获取边框
ax.spines['bottom'].set_linewidth(bwith)
ax.spines['left'].set_linewidth(bwith)
ax.spines['top'].set_linewidth(bwith)
ax.spines['right'].set_linewidth(bwith)#设置边框
x_major_locator=MultipleLocator(1)
y_major_locator=MultipleLocator(10)
ax.xaxis.set_major_locator(x_major_locator)
ax.yaxis.set_major_locator(y_major_locator)#设置刻度间隔
ax.tick_params(axis='x',width=0.4,length=1.5)#设置表示方向的线段
ax.tick_params(axis='y',width=0.4,length=1.5)
plt.tight_layout()
plt.show()
标签:plot,major,set,locator,plt,绘图,ax,linewidth 来源: https://blog.csdn.net/qq_32649321/article/details/121870868