I used this: https://mathematica.stackexchange.com/questions/19859/plot-extract-data-to-a-file initially. The first element in the plot dynamicalStream
was an empty string plus an object GraphicsComplex
. I extracted the points from the plot with points = dynamicalStream[[1]][[2]][[1]]
. It may be different for someone else. The Line
objects from this GraphicsComplex
object were extracted with (and I apologise for the way I did this, there are probably better methods)
lines = dynamicalStream[[1]][[2]][[2]][[2]][[3]][[2 ;; Length[ dynamicalStream[[1]][[2]][[2]][[2]][[3]]]] ].
I'd say this is unlikely to be useful, so either you find a more general method or do what I did which is manually find the correct part of the list to extract from.
I then created a list where each element is itself a list of points for each line. This was done with pointstable =
Table[points[[#[[1]][[i]]]], {i, 1, Length[#[[1]]]}] & /@ lines
. The inner list was created by going through each element in the Line
object (this is a position of a point in the points
list) and extracting the correct point. Thus you make a list of points corresponding to the Line
. This is then mapped over each Line
object in lines
so the final list is of the described form.
I then saved each list in a separate text file:
Export["line" <> IntegerString[#2] <> ".txt", #,"Table"] &~MapIndexed~pointstable
as described in the link.
I plotted with:
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={decoration={
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}}}
\tikzset{-<-/.style={decoration={
markings,
mark=at position #1 with {\arrow{<}}},postaction={decorate}}}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[axis lines=none]
\foreach \i in {1,2,3,4,...,107}{
\addplot[black,->-=0.5] table[]{line\i.txt};
}
\end{axis}
\end{tikzpicture}
\end{document}
After looking at that link properly, an easier way to do it would be:
points = Cases[dynamicalStream, GraphicsComplex[data__] :> data, -3, 1][[1]]
lines = Cases[dynamicalStream, Line[data__] :> data, -3];
pointstable = Table[points[[#[[i]]]], {i, 1, Length[#]}] & /@ lines