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

1 次查看(过去 30 天)
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