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.

조회 수: 13 (최근 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
Caleb
Caleb 2012년 9월 13일
편집: Caleb 2012년 9월 13일
% create data
A = rand(1,10);
% plot data
bar(A);
% obtain statistics
meanA = mean(A);
medianA = median(A);
min = min(A)
max = max(A)

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

채택된 답변

Kevin Claytor
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.
  댓글 수: 2
Caleb
Caleb 2012년 9월 13일
Can I annotate the marker placed on the graph? I want to show the actual value and not just the location.
Caleb
Caleb 2012년 9월 13일
Also, the curve has little to do with the data. I want to use the data to form the curve.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by