Trying to add horizontal line on a graph
4 次查看(过去 30 天)
显示 更早的评论
So im trying to add a horizontal line to to show the mean gradient to the graph on the bottom.
The mean is -0.0714 and i want to draw this line as a dotted line. iv tried all sorts of things on this forum but cant seem to get it
Thanks in advance
0 个评论
回答(1 个)
Walter Roberson
2016-11-8
XL = xlim();
plot( XL, [TheMean, TheMean])
2 个评论
Walter Roberson
2016-11-8
Example:
plot(x,y)
x = 1:30;
y = sin(x)+x;
TheMean = mean(y);
plot(x,y)
hold on
XL = xlim();
plot(XL, [TheMean TheMean], 'g--')
hold off
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!