How do I vary the color of a line with time when the X and Y data overlap?
조회 수: 1 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161878/image.jpeg)
I'm collecting data from some extensometers that show soil displacements in response to barometric pressure fluctuations. When the displacement data is plotted against the barometric data (to get a coefficient), the plot appears like a series of "squiggles" (see photo). When I use the patch() function, the polygons are filled in with color. I only want the color of the line to vary with time. Does anyone know how to accomplish this? I've tried surf(), but was unable to plot.
x = BaroP_Avg; % Barometric Pressure Data [kPa] y = X8; % Displacement Data [microns] col = time; figure();patch(x,y,col);
Thanks, Rob
댓글 수: 0
답변 (1개)
Renee Coetsee
2017년 3월 23일
The documentation for "patch" has an example on how to create a multicolored line. It works by setting the last entry of y to NaN so that patch creates a line instead of a closed polygon, then setting the 'EdgeColor' patch property. You can see more details in the "Create Multicolored Line" example in the patch documentation page:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!