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?
68 次查看(过去 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 个评论
Walter Roberson
2020-10-29
xline() starting from R2018b https://www.mathworks.com/help/matlab/ref/xline.html
回答(1 个)
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)
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!