创建第二个轴。
x=-3.14:.1:3.14;
y=sin(x);
h=plot(x,y);
ax1=findobj(gcf,'Type','axes'); %save first axis handle
%set first stype
set(gca,'Xcolor',[0 0 0],'Xtick',[-3,-2,-1,1,2,3],'gridlinestyle','-','xgrid','on')
%create new axis
ax2=axes('position',get(gca,'position'),'Visible', 'on');
set(ax2,'YTick',[],'Xcolor','blue','Xtick',[-2.5 0 2.5],'xgrid','on','color','none'); %color none to make the axis transparent
set(ax2,'xlim',get(ax1,'xlim')) %resize 2nd axis to match 1st
生产: