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

1 visualización (últimos 30 días)
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

Respuestas (1)

Renee Coetsee
Renee Coetsee el 23 de Mzo. de 2017
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:

Community Treasure Hunt

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

Start Hunting!

Translated by