I want to plot a line over a bar graph that shows a smooth distribution and display the mean, median, and range of the data.
15 次查看(过去 30 天)
显示 更早的评论
First, how do I overlay information on a plot. I want to give the mean, median and range of a distribution inside the axes figure.
Also, how do I overlay a smooth line over my bar graph to give a more visually appealing view of the distribution?
2 个评论
采纳的回答
Kevin Claytor
2012-9-13
You can use hold on to overlay plots (scaling factors 300, 150, 125 chosen to arbitrarily);
A = randn(1000,1);
hist(A)
hold on
x = linspace(-4,4);
plot(x,exp(-x.^2)*300,'r')
plot(meanA,150,'kd');
plot(medianA,150,'ko');
plot([min(A),max(A)],125,'ko');
Also, naming variables after functions (min = min(A)) is bad form.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!