Plotting Vector Fields

Hello,

I'm trying to plot some basic vector fields - I've looked around and it seems that Gizmo's "scatter arrows" experiment is the best that Igor has to offer. I'm not really impressed with the interface nor how the plots look.

Are there any other options for plotting vector fields?

Any help would be greatly appreciated.

Regards,
-Willy Voje
Quote:
Are there any other options for plotting vector fields?


Yes. Here is a very simple example:
// Make XY data
Make/O xData = {1, 2, 3}, yData = {1, 2, 3}
Display yData vs xData                // Make graph
ModifyGraph mode(yData) = 3        // Marker mode
 
// Make an arrow data wave to control the length and angle for each point.
Make/O/N=(3,2) arrowData    // Controls arrow length and angle
Edit /W=(439,47,820,240) arrowData
 
// Put some data in arrowData
arrowData[0][0]= {20,25,30}    // Column 0: arrow lengths in points
arrowData[0][1]= {0.523599,0.785398,1.0472}        // Column 1: arrow angle in radians
 
// Set trace to arrow mode to turn arrows on
ModifyGraph arrowMarker(yData) = {arrowData, 1, 10, 1, 1}
 
// Make an RGB color wave
Make/O/N=(3,3) arrowColor
Edit /W=(440,272,820,439) arrowColor
 
// Store some colors in the color wave
arrowColor[0][0]= {65535,0,0}        // Red
arrowColor[0][1]= {0,65535,0}        // Green
arrowColor[0][2]= {0,0,65535}        // Blue
 
// Turn on color as f(z) mode
ModifyGraph zColor(yData)={arrowColor,*,*,directRGB,0}


For details read about the arrowMarker keyword of the ModifyGraph operation.

Also choose File->Example Experiments->Feature Demos2->Barbs and Arrows.

And File->Example Experiments->Graphing Techniques->Arrow Plot.
WmVoje wrote:
Hello,

I'm trying to plot some basic vector fields - I've looked around and it seems that Gizmo's "scatter arrows" experiment is the best that Igor has to offer. I'm not really impressed with the interface nor how the plots look.


It would be best if you specified the dimensionality of your vector fields. If 2D then the example above should work. If 3D you have to use Gizmo.

I agree, Scatter Arrows is not a particularly impressive example. It was created to illustrate a technique and not as a marketing tool. It could, for example look more like the attached image or with a bit more effort you can plaster an image of your favorite politician on each arrow. So, tell us what you need and we'll try to suggest a solution.

A.G.
WaveMetrics, Inc.
screenshot_35.png (31.87 KB)
Sorry that I keep coming back to this issue, but is there an example to make a vector field plot of a 2d function? That is, I would like to be able to specify 2 2d functions, e.g. fx[][] and fy[][] (or fr[][] and ftheta[][], if you prefer) that are defined on a grid of points in the usual way by x and y scaling and give the x and y (or r and theta) components of an arrow that is to be plotted at the center of each "pixel" defined by the image.

The example experiment depends on some complicated seeming footwork to get 2 1d curves to raster scan through the whole 2d space. That is clunky and hard to get right. It would be nice to have a routine where you just give it the functions and Igor does the rest (perhaps using redimension in a fancy way?)

The imagined function might have syntax such as

DoVectorFieldPlot(fx,fy)

Function DoVectorFieldPlot(fx,fy,lineThick,headLen,headFat,posMode)
wave fx,fy
variables lineThick,headLen,headFat,posMode
....
Display ....
End


Thanks,

John Bechhoefer
Department of Physics
Simon Fraser University
Burnaby, BC, Canada

PS Please don't use a complex wave to represent the two components. That's unintuitive and requires that an eventual generalization to 3d use a different syntax.
Greetings. I just wanted to share that I've had good success using the method outlined by Mr. Rodstein to generate 2D vector field plots. Below is an example of the commands used with reasonable success. In the imported data file the first 3 columns are X,Y,Z coordinate data in cylindrical coordinates (Z=0 for all points). The subsequent columns are magnitude and phase data from FFT results. Each row represents a different point in space. So here I am reading in the data, converting it to Cartesian X-Y coordinates, adding vector arrows at each point to show magnitude and phase of the calculated force harmonic at a given point. In this case I am grabbing columns 13 and 14 which are the magnitude and phase of the 6th harmonic in my data set. I'm also using the magnitude for coloration of the vector plot. It all worked quite nicely. Note that my 3rd to last line is used to scale the size of the arrows without changing the stored column data.

•LoadWave/G/D/W/E=1 "C:Lorenz:ANSYS:APDL scripting:forcesxFFT_data.txt"
•duplicate wave0 xcoord
•duplicate wave1 ycoord
•xcoord=wave0*cos(wave1*3.14159/180)
•ycoord=wave0*sin(wave1*3.14159/180)
•Edit xcoord,ycoord
•Display ycoord vs xcoord
•ModifyGraph mode(ycoord)=3
•ModifyGraph msize=0.1
•Make/O/N=(7950,2) arrowData
•Edit arrowData
•arrowData[][0]=wave13[p]
•arrowData[][1]=wave14[p]
•ModifyGraph arrowMarker(ycoord) = {arrowData,1,5,1,0}
•arrowData[][0]=arrowData[p][0]*2
•ModifyGraph rgb=(0,0,0)
•ModifyGraph zColor(ycoord)={wave13,*,*,Rainbow,1}

Joshua Lorenz
Kato Engineering