2D/3D Vector Data and Raster Map

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 4 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.

         program vector
   c Specify that data is to be vectors
   c Set the maximum and minimum x, y and z-values
   c  Set a scale factor to control the length of the vectors
         z = 0.0
         vz = 0.0
         y = ymin - dy
         do 1 n = 1,nmax
         x = xmin
         y = y + dy
         do 2 m = 1,mmax
         vx = 2.0*x
         vy = -2.0*y
   c  Write the coordinates of the tail and the components of vector
         x = x + dx
   2     continue
   1     continue
   100   format(3f10.2,'   `,3f10.2)

Figure 6 contains the result of using plotmtv with command line options -pfg WHITE and -pbg NAVY to view the data set produce by Code 4. Figure 6 demonstrates one of the frequently encountered problems one 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.

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 7, which was created by combining Codes 2 and 4 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 6. Using the command line syntax

plotmtv -pfg BLACK -pbg WHITE -plotall test1.dat vect.dat

permits the simultaneous display of the two data sets on a single plot. Remember that test1.dat comes from running program cont with contour style = 2, and vect.dat comes from this section's program vector.

Figure 7 Color raster map of x - y with the vector field (2x,-2y) superimposed

Next Section: Exercises

Previous Section: 3-Space Mapping

Table of Contents (Overview)

Back to CSEP