I want to include a vertical line on the histogram, so it shows the location of the mean. The mean value is 5.12, how can I modify this code?

66 ビュー (過去 30 日間)
subplot(2,1,1)
histogram(LotH);
grid on;
title("Graph of (LotH)");
xlabel("LotH");
ylabel("Scores");
hold on;
line([0,5.12], ylim, 'LineWidth', 2, 'Color', 'r');

回答 (1 件)

Rik
Rik 2020 年 10 月 28 日
You are not plotting a vertical line. The coordinates you're using are (0,y_min) and (5.13,y_max), which is not a vertical line. You need to use this:
line(5.12*[1 1],ylim)
Or consider using the xline function (introduced in R2018b)
  2 件のコメント
Ahmed
Ahmed 2020 年 10 月 29 日
how can I include vertical dotted lines on histogram to show the cutoff of the outliers?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by