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

    %% Add Title and Axis Labels and Format Ticks 
% For $t$ values in the range $-2\pi$ to $2\pi$, plot the parametric line
% 
% $$\matrix{x = t \cr y = t/2 \cr z = \sin(6t).}$$
% 
% Add a title, _x_-axis label, and _y_-axis label. Additionally, change the
% view of the axes and display the axes box outline.

xt = @(t)t;
yt = @(t)t/2;
zt = @(t)sin(6*t);
fplot3(xt,yt,zt,[-2*pi 2*pi],'MeshDensity',30,'LineWidth',1);

title('x=t, y=t/2, z=sin(6t) for -2\pi<t<2\pi')
xlabel('x');
ylabel('y');
view(52.5,30)
box on

%%
% Access the axes object using |gca|. Specify the _x_-axis tick values and
% associated labels using the |XTick| and |XTickLabel| properties of the
% axes object. Similarly, specify the _y_-axis tick values and associated
% labels.
ax = gca;
ax.XTick = -2*pi:pi/2:2*pi;
ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0','\pi/2','\pi','3\pi/2','2\pi'};
ax.YTick = -pi:pi/2:pi;
ax.YTickLabel = {'-\pi','-\pi/2','0','\pi/2','\pi'};