How to change plot background color for some datapoints?
조회 수: 19 (최근 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에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!