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

    %% Display _x_-Axis Tick Labels in Terms of Pi
% Create a line plot. Specify the _x_-axis limits and display tick marks
% along at 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 text for each label.
xticklabels({'0','\pi','2\pi','3\pi','4\pi','5\pi','6\pi'})