Histogram xlabel, ylabel, and title.

조회 수: 159 (최근 30일)
Paul Yanik
Paul Yanik 2019년 12월 19일
댓글: Allen 2019년 12월 19일
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.
Code:
xlabel = ('Length');
ylabel = ('Count');
title = ('Histogram of salmon lengths');
histogram(salmon_length,edges,'DisplayStyle','stairs');

채택된 답변

Allen
Allen 2019년 12월 19일
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.
histogram(salmon_length,edges,'DisplayStyle','stairs');
% Now that a graphics object (histogram plot axes) exists, the following functions will target the
% active axes.
xlabel('Length')
ylabel('Count')
title('Histogram of salmon lengths')
  댓글 수: 2
Paul Yanik
Paul Yanik 2019년 12월 19일
Great! Thanks for your help.
Allen
Allen 2019년 12월 19일
Your welcome. If the solution worked, don't forget to accept the answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by