Shading an area across zero
1 次查看(过去 30 天)
显示 更早的评论
I have a plot of zscores and would like to highlight a particular area of the graph. This is the relevant code i'm using:
xmin = plot_time-time_period; xmax = plot_time; %called from a matrix
x = [xmin xmax];
yLimits = get(gca,'YLim');
h1 = area(x,[yLimits(1) yLimits(1)]);
h2 = area(x,[yLimits(2) yLimits(2)]);
set(h1,'Facecolor','k')
set(h2,'Facecolor','k')
alpha(0.15)
Which produces this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149229/image.jpeg)
I would like to remove the line across zero, but the following code just creates nonsense:
h1 = area(x,[yLimits(1) yLimits(2)]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149231/image.jpeg)
Any ideas? Thanks.
0 个评论
回答(2 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!