- 所有坐标轴显示刻度:
plt.tick_params(top='on', right='on', which='both')
- 主刻度和次刻度都朝里:
ax.tick_params(direction='in',which='both')
- 设置y轴刻度值标签旋转90°:
- 设置坐标轴刻度标签大小:
ax.tick_params(labelsize=14)
- 不显示刻度和刻度值标签:
ax.set_xticks([])
显示刻度,但不显示刻度值标签:
ax.set_xticklabels([])
- 将纵轴刻度值的中心与刻度对应
for label in ax.get_yticklabels():
label.set_verticalalignment('center')
- 设置刻度
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator,MaxNLocator)
- 100为单位的主刻度
ax.yaxis.set_major_locator(MultipleLocator(100))
- 20为单位的次刻度
ax.yaxis.set_minor_locator(MultipleLocator(20))
- 共设置四个刻度
ax.yaxis.set_major_locator(MaxNLocator(4))
画图常用
import matplotlib
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
ax.set_xlim([1/float(NBIN)*360-180,NBIN/float(NBIN)*360-180])
ax.minorticks_on()
ax.set_xticklabels([])
ax.set_xlabel("Longitude ($^\circ$)",fontsize=14)
ax.set_ylabel("Norm. I",fontsize=14)
ax.tick_params(axis='y', rotation=90)
ax.tick_params(top=True,right=True,direction='in',which='both',labelsize=14)
ax.text(0.04,0.94,textT,rotation='horizontal',horizontalalignment='left',verticalalignment='top',transform=ax.transAxes,fontsize=13,linespacing=1.6)