Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
See also How to prepare data for ListVectorPlot –  Jens Mar 17 '13 at 19:21
add comment

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
    
@ernst-stelzer FYI: ListVectorPlot did not crash my kernel in v9.0.1 (Mac OS X 10.8.2) –  zentient Mar 17 '13 at 12:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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