0
$\begingroup$

I have a list with [x,y,u,v] and the list size is 3240 x 4.

I am using the below code to plot the vectors,

a = Import["/Users/user/Desktop/test.csv", "CSV"];
x = a[[All, 1]];
y = a[[All, 2]];
u = a[[All, 3]];
v = a[[All, 4]];
data = MapThread[{{#1, #2}, {#3, #4}} &, {x, y, u, v}];
ListStreamPlot[data, StreamPoints -> Fine, StreamColorFunction -> "Rainbow"]

The result is as follow,

enter image description here

I want more number of lines and if possible a continuous line with multiple arrowheads. Can anyone help me?

PS: I want to attach my CSV but don't know how to do.

$\endgroup$
  • $\begingroup$ StreamPoints -> Fine? $\endgroup$ – Feyre Aug 31 '16 at 15:05
  • $\begingroup$ @Feyre I have added that also. But not much change :( $\endgroup$ – Selva Aug 31 '16 at 15:13
1
$\begingroup$

If the Stream Points Options of ListStreamPlot do not help I would suggest generating an interpolation of your vector field and to use StreamPlot with that interpolation, assuming your vector field is smoth enough. So first a set of sample data and its interpolation:

data = Table[{{x,y},{-1-x^2+y,1+x-y^2}},{x,-3,3,.5},{y,-3,3,.5}];
v = Interpolation@Flatten[data, 1]

Now we can plot this interpolatet vector field with StreamPlot and use all of its options:

StreamPlot[v[x,y],{x,-3,3},{y,-3,3},
StreamPoints->Fine,StreamScale->Large,PlotRangePadding->None]

StreamPlot

All Options of StreamPlot should work with the interpolation function.

But if you want really nice StreamPlots you will have to tweak that quite a bit: I personaly dislike Mathematicas plotting tools for stream and vector plots. I would recommend looking at matplotlib of Python: it generates very nice Plots and they are much easier to export and look well after export. But no hate on Mathematica with tweaking you might get good plots with it as well and with more tweaking even nice ones after export.

| improve this answer | |
$\endgroup$
  • $\begingroup$ As you suggested, I tried StreamPlot[v[x, y], {x, -10, 0}, {y, -38, -35}] but then I am getting error as The point -16.955 in dimension 1 is duplicated. $\endgroup$ – Selva Aug 31 '16 at 16:22
  • 1
    $\begingroup$ Can you upload your dataset somewhere? Dropbox, Onedrive or elsewhere? I can not say to much without having the data. $\endgroup$ – N0va Aug 31 '16 at 16:35
  • $\begingroup$ Sure. Click Here for data. BTW, thanks for your help... $\endgroup$ – Selva Aug 31 '16 at 16:41
  • $\begingroup$ data = Import["test.csv"]; vdata = Table[{data[[i, {1, 2}]], data[[i, {3, 4}]]}, {i, 1,Length@data}]; v = Interpolation[vdata] StreamPlot[v[x, y], {x, -10, 0}, {y, -38, -35}, StreamPoints -> Fine, StreamScale -> Large, PlotRangePadding -> None] Works for me. $\endgroup$ – N0va Aug 31 '16 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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