Histogram xlabel, ylabel, and title.
497 views (last 30 days)
I am trying to add simple labels (xlabel, ylable, title) to a histogram with the following code. The histogram appears, but labels do not.
Any help would be appreciated.
xlabel = ('Length');
ylabel = ('Count');
title = ('Histogram of salmon lengths');
Allen on 19 Dec 2019
Paul, the order that you are calling the functions is incorrect. You need to create the histogram plot prior to assigning labels and a title. Also, you are using the xlabel, ylabel, and title functions with the wrong syntax. What you are using is basically creating a variable with the same name as the xlabel, ylabel, and title functions. See example below.
% Now that a graphics object (histogram plot axes) exists, the following functions will target the
% active axes.
title('Histogram of salmon lengths')