For example, how can I extract the black, red, blue parts of a line, and another green line in the diagram below as four separate data sets?
Here is my attempt and code, but it hasn't been successful.
I would appreciate any help, thank you!
SetOptions[Plot, ColorFunctionScaling -> False];
colorfun =
Function[{x, y}, If[Cos[x] > 0, Red, If[x y < 0, Blue, Black]]];
tend = 10;
fig = Show[{Plot[Sin[Cos[t^2]], {t, 0, tend},
ColorFunction -> colorfun],
Plot[Cos[Sin[t^2]], {t, 0, tend},
PlotStyle -> {Thin, Green, Dashed}]}, PlotRange -> All]
dat = Cases[InputForm@fig, Line[x_] :> x, ∞];
ListPlot[Evaluate@dat]