www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/IncrementxAxisTickValuesByPiExample.m

    %% Increment _x_-Axis Tick Values by Pi
% Create a line plot. Specify the _x_-axis limits as 0 to $6\pi$. Then,
% display tick marks along the _x_-axis at increments of $\pi$.

x = linspace(0,6*pi);
y = sin(x);
plot(x,y)
xlim([0 6*pi])
xticks(0:pi:6*pi)

%%
% MATLAB(R) labels the tick marks with the numeric values. Change the
% labels to show the $\pi$ symbol by specifying the text for each label. 

xticklabels({'0','\pi','2\pi','3\pi','4\pi','5\pi','6\pi'})