How to change plot background color for some datapoints?
9 次查看(过去 30 天)
显示 更早的评论
I would like to produce a plot as shown below. The feature I am looking are the different background colors for some of the datapoints. How can I do this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159995/image.png)
Thank you!
0 个评论
采纳的回答
Walter Roberson
2016-4-4
You can use rectangular regions with fill(), or you can use rectangle() with a FaceColor . Either way, you can draw those background areas first, or if you draw them after the plot be sure to uistack() them to the beneath the plot lines.
5 个评论
Claire Andreasen
2020-8-17
if you're using a grid, how would you make the grid appear overtop the rectangle?
Walter Roberson
2020-8-17
Grids are considered part of an axes. You can have axes appear on top by setting the axes Layer property to 'top' instead of the default 'bottom'
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!