龙听期货论坛's Archiver

龙听 发表于 2019-5-10 14:42

MATLAB画图:改变坐标轴刻度的显示数值

改变坐标轴显示数值,可以用:set(gca,'xtick',xtick,'xticklabel',xticklabel) ;gca表示Get Current Axis的Handle,xtick表示显示刻度的位置,xticklabel表示显示的内容。Example: (from MATLAB Help)[color=#494949][font=Consolas, &quot][size=12px][font=Verdana, Geneva, Arial, Helvetica, sans-serif][size=9px][b][plain][/b] [url=http://blog.csdn.net/xianrudu/article/details/8044606#]view plain[/url][url=http://blog.csdn.net/xianrudu/article/details/8044606#]copy[/url]
[/size][/font]

[list=1][*]x = -pi:.1:pi;  [*]y = sin(x);  [*]plot(x,y)  [*]set(gca,'XTick',-pi:pi/2:pi)  [*]set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'})  [*]title('Sine Function');  [*]xlabel('Radians');  [*]ylabel('Function Value');  [/list][/size][/font][/color]

页: [1]