4
$\begingroup$

Can I somehow plot a vector field and the scattered data point associated with each and every vector? Also, is there any way to prevent Mathematica from interpolting the vector field?

I am trying to plot this data as a vector field. The data is from a .dat file that includes the following four columns: x-coord, y-coord, vecx, vecy.

http://wikisend.com/download/386548/testBC.dat

I managed to plot the following with Tecplot

enter image description here

I am trying to remake this plot in Mathematica

testBC = Import["C:\\...testBC.dat", "Table", "IgnoreEmptyLines" -> True];
testBCx = testBC[[All, 1]];
testBCy = testBC[[All, 2]];
ux = testBC[[All, 3]];
uy = testBC[[All, 4]];
u = Transpose[{ux, uy}];
testbdry = Transpose[{testBCx, testBCy}];
ListVectorPlot[Transpose[{testbdry, u}], PlotRange -> Full, 
VectorPoints -> 10, VectorScale -> {0.1, 0.2}]

Results in the following

enter image description here

Mathematica interpolates the inside of the airfoil.

How can I remake the plot from Tecplot, i.e., how can I show the scatter plot of x, y, and the vectors pointing away from every point. Also, I want Mathematica to plot all the vectors as in Tecplot, not to only sample and interpolate.

$\endgroup$
1

2 Answers 2

5
$\begingroup$

I saved the data on my desktop and imported it. To my surprise ListVectorPlot crashed my kernel.

orgData = Import["C:\\Users\\stelzer\\Desktop\\testBC.txt", "Data"];

Graphics[{Arrowheads[Small], Arrow[{{#1, #2}, {#1, #2} + 0.03 {#3, #4}}] & @@@ 
   orgData}, Frame -> True, FrameLabel -> {"v1", "v2"}]

enter image description here

$\endgroup$
6
$\begingroup$

I think you're looking for the option "VectorPoints -> All"; I think this achieves both your goals (one vector per coordinate and no interpolation):

testBC = Import["~/Downloads/testBC.dat", "Table", "IgnoreEmptyLines" -> True];
testBCx = testBC[[All, 1]];
testBCy = testBC[[All, 2]];
ux = testBC[[All, 3]];
uy = testBC[[All, 4]];
u = Transpose[{ux, uy}];
testbdry = Transpose[{testBCx, testBCy}];
ListVectorPlot[Transpose[{testbdry, u}], 
    PlotRange -> Full, 
    VectorPoints -> All, 
    VectorStyle -> Automatic,
    AspectRatio -> 1/2, 
    VectorScale -> {0.1, 0.2}]

Which gives the following result:

enter image description here

Note that I also changed the AspectRatio to approximate your initial plot image above.

$\endgroup$
1
  • $\begingroup$ @ernst-stelzer FYI: ListVectorPlot did not crash my kernel in v9.0.1 (Mac OS X 10.8.2) $\endgroup$ Mar 17, 2013 at 12:46

Your Answer

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

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