參考鏈接
https://blog.csdn.net/weixin_34498545/article/details/112631706
進行初始化 plt.figure(figsize = (8,6)) ax = plt.gca()
調整坐標軸范圍 x軸 ax.set_xlim() y軸 ax.set_ylim() 設置在 0 - 8 之間 ax.set_xlim(0,8) ax.set_ylim(0,8)
設置 x 軸 y 軸 標題 ("內容",fontsize = ,color = ,alpha = , bbox = ,) ax.set_xlabel() ax.set_ylabel() 參數示例 ax.set_xlabel("X軸",fontsize = 14,color = 'b',alpha = 0.7,bbox=dict(boxstyle='round,pad=0.5', fc='yellow', ec='blue',lw=1 ,alpha=0.7)) ax.set_ylabel("Y軸",fontsize = 14,color = 'b',alpha = 0.7,bbox=dict(boxstyle='round,pad=0.5', fc='yellow', ec='blue',lw=1 ,alpha=0.7))
修改默認刻度文字 (列表 , family = , fontsize = ,) ax.set_xticklabels() ax.set_yticklabels() ax.set_xticklabels(['A','B','C','D','E','F','G']) ax.set_yticklabels(['鑒','圖','化','視','可','注','關'], family = 'SimHei',fontsize = 14)
突出主副刻度 使用 tick_params 對刻度線進行調整 tick_params(which = , length = , labelsize = ,) tick_params(which='major',length=8,labelsize=10) tick_params(which='minor',length=4)
調整 坐標軸 刻度 距離
默認刻度 locator 位置 MultipleLocator 樣式 FormatStrFormatter from matplotlib.ticker import MultipleLocator, FormatStrFormatter xmajorLocator = MultipleLocator(1) ax.xaxis.set_major_locator(xmajorLocator) ymajorLocator = MultipleLocator(1) ax.yaxis.set_major_locator(ymajorLocator) xminorLocator = MultipleLocator(0.25) ax.xaxis.set_minor_locator(xminorLocator) yminorLocator = MultipleLocator(0.25) ax.yaxis.set_minor_locator(yminorLocator) MultipleLocator(1) 表示刻度之間的間隔為 1
