www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/AddTitleAndAxisLabelsAndFormatTicksContourExample.m
%% Add Title and Axis Labels and Format Ticks % Plot $x\sin(y)-y\cos(x)$. Display the grid lines, add a title, and add % axis labels. fcontour(@(x,y) x.*sin(y) - y.*cos(x), [-2*pi 2*pi], 'LineWidth', 2); grid on title({'xsin(y) - ycos(x)','-2\pi < x < 2\pi and -2\pi < y < 2\pi'}) xlabel('x') ylabel('y') %% % Set the _x_-axis tick values and associated labels by setting the % |XTickLabel| and |XTick| properties of the axes object. Access the axes % object using |gca|. Similarly, set the _y_-axis tick values and % associated labels. ax = gca; ax.XTick = ax.XLim(1):pi/2:ax.XLim(2); ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0','\pi/2','\pi','3\pi/2','2\pi'}; ax.YTick = ax.YLim(1):pi/2:ax.YLim(2); ax.YTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0','\pi/2','\pi','3\pi/2','2\pi'};