next up previous

4. Vector Fields

To illustrate how to display vector data, we begin with a two dimensional vector field that is the gradient of the function , which was used to illustrate contour, raster and surface plots in the previous section. Code 3 illustrates how to write a simple MTV data file containing the vector field (vx,vy,vz) = (2x,-2y,0) on a 25x25 grid over the square 0 < x,y < 5. Note that even though a two dimensional vector field is to be displayed, it is necessary to write the vector data set in the form x y z vx vy vz, where x,y,z specify the tail of a given vector and vx,vy,vz designate the components of the vector.

Click here to have plotmtv plot this vector field.

Figure 5 contains the result of using plotmtv with command line options -pfg BLACK and -pbg WHITE to view the data set produced by Code 3. Figure 5 demonstrates a problem one frequently encounters when displaying vector data. Namely, when vectors of markedly different magnitudes are present in the data set, it is difficult to select a scale factor that makes the smallest of the vectors visible, yet prevents the longer vectors from overlapping their neighbors. When this situation is encountered, a number of techniques may help with the visualization of the data.

Figure 5 Plot of Vector Field (2x,-2y) from Code 3

One technique is to normalize the length of all the vectors to unity and then set the line color of vectors in proportion to their magnitude. In such a scheme, the arrows show the flow of the vector field and their colors indicate the "speed" of the flow. A second technique, when plotting 2D vector fields, is to again normalize the magnitude of the vectors and use the z component of the tail of the vector to represent the speed of the flow. Thus, the vectors are displayed as horizontal arrows on a surface whose height represents the magnitude of the vector. Yet another technique is to plot the magnitude of the vector field as a contour or color raster map and then overlay normalized vectors indicating the direction of flow.

The final illustration in this quick start is presented in Figure 6, which was created by combining Codes 2 and 3 to write a file containing two MTV data sets. The first data set contains the raster map of Figure 3, while the second data set contains the vector field of Figure 5. Using the command line syntax

permits the simultaneous display of the two data sets on a single plot.

Figure 6 Color Raster Map of x^2 - y^2 with the Vector Field (2x,-2y)