Advertisement
Guest User

Untitled

a guest
Aug 1st, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Matlab Grid lines with different color on one axis
  2. plot(x,y,'--g')
  3. set(gca,'Xcolor',[0 0 0],'Xtick',[12e3,14e3,18e3,23e3,30e3,37e3,57e3],
  4. set(gca,'Xcolor',[0.5 0.9 0.5],'Xtick',[10e3 16 28e3]);
  5.  
  6. x=-3.14:.1:3.14;
  7. y=sin(x);
  8.  
  9. h=plot(x,y);
  10. ax1=findobj(gcf,'Type','axes'); %save first axis handle
  11.  
  12. %set first stype
  13. set(gca,'Xcolor',[0 0 0],'Xtick',[-3,-2,-1,1,2,3],'gridlinestyle','-','xgrid','on')
  14.  
  15. %create new axis
  16. ax2=axes('position',get(gca,'position'),'Visible', 'on');
  17. set(ax2,'YTick',[],'Xcolor','blue','Xtick',[-2.5 0 2.5],'xgrid','on','color','none'); %color none to make the axis transparent
  18. set(ax2,'xlim',get(ax1,'xlim')) %resize 2nd axis to match 1st
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement