MATLAB: How to label the y-axes with a percent sign (%) in MATLAB

%axesbargraphhistlabel;MATLABpercentplotticklabelticksy

I would like to change the axis tick labes to a percentatge of a number rather than just that set of numbers.

Best Answer

This can be done after plotting your figure. The code given below shows an example on how to get the current axis labels and format them into a string with the percent symbol. Once this is done it sets the axis tick labels back to the figure axis.
surf(peaks)
% lines 6,7,8 get the axis labels.
% lines 10,11,12 create the respective Percent vectors
% lines 14,15,16 concatenate the vectors
xticks = [get(gca,'xtick')]'; % Gets the axis tick labels.
yticks = [get(gca,'ytick')]'; % There is a transpose operation here.
zticks = [get(gca,'ztick')]'; %
percentsx = repmat('%', length(xticks),1); % makes a matrix
percentsy = repmat('%', length(yticks),1); % equal to the size
percentsz = repmat('%', length(zticks),1); % of the number of ticks
xticklabel = [num2str(xticks) percentsx];
yticklabel = [num2str(yticks) percentsy]; % concatenates the tick labels
zticklabel = [num2str(zticks) percentsz]; %with percentages
set(gca,'xticklabel',xticklabel)
set(gca,'yticklabel',yticklabel)% Sets tick labels back on the Axis
set(gca,'zticklabel',zticklabel)
% Sets them back on the Axis