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

    %% Display _x_-Axis Tick Labels in Dollars
% Display _x_-axis tick labels in dollars with and without decimal values.
%
% Create a bar chart. Display the tick labels along the _x_-axis in 
% dollars. 

x = 0:20:100;
y = [88 67 98 43 45 65];
bar(x,y)
xtickformat('usd')

%%
% Query the tick label format. MATLAB(R) returns the format as a character
% vector containing the formatting operators.

fmt = xtickformat


%%
% Display the tick labels with no decimal values by tweaking the numeric
% format to use a precision value of 0 instead of 2. 

xtickformat('$%,.0f')