Histogram xlabel, ylabel, and title.

406 ビュー (過去 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 Center および File ExchangeHistograms についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by