필터 지우기
필터 지우기

How do I vary the color of a line with time when the X and Y data overlap?

조회 수: 1 (최근 30일)
Rob Moak
Rob Moak 2017년 3월 19일
답변: Renee Coetsee 2017년 3월 23일
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

답변 (1개)

Renee Coetsee
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:

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by