I have a table that I use to generate a streamplot using the command ListStreamPlot. I would like somehow to export the plot to a tikz file. This is because I will need to do some post-processing and I want to make sure that every figure in the paper is consistent (all the other plots are rendered with PGFPlots).

I could not find a smart way to achieve this. How can I extract the data from the plot so that I can embed them in a tikz file?

Thank you


1 Answer 1

(* fake data *)
data = Table[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3, .2}, {y, -3, 3, .2}];
(* create plot *)
g = ListStreamPlot[data];
(* get all the arrows *)
c = Cases[g, Arrow[__], 6]
(* create the data *)
dataAsString = ExportString[c /. {Arrow -> Catenate}, "CSV"]
  • $\begingroup$ This is simple and effective. Outstanding! $\endgroup$
    – sbozzolo
    Jun 5, 2018 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.