## 3. Contours, Raster Maps and Surfaces

This section illustrates the use of plotmtv in viewing data sets of the form z = f(x,y) where x and y range over a rectangular mesh. The following code, cont.f illustrates the construction of an MTV data file containing the information necessary to plot the function over the region 0 < x,y < 5.

### Code 2:

program cont parameter(mmax=25,nmax=25) parameter(xmin=0.0,ymin=0.0,xmax=5.0,ymax=5.0) parameter(dx=(xmax-xmin)/mmax,dy=(ymax-ymin)/nmax) dimension u(0:mmax,0:nmax) write(6,*)'Available contour styles are:' write(6,*)'normal contours -- contstyle = 1' write(6,*)'gradated colors -- contstyle = 2' write(6,*)'3D surface mesh -- contstyle = 3' write(6,*)'Please enter a value for contstyle' read*,i open(4,file='test1.dat',status='unknown') c Specify that data are to be contoured write(4,*)'\$DATA=CONTOUR' c Specify the style of the contour map write(4,*)'%contstyle=',i c Set the number of data points in the x and y directions write(4,*)'%nx=',mmax+1 write(4,*)'%ny=',nmax+1 c Set the maximum and minimum x and y-values write(4,*)'%xmin=',xmin write(4,*)'%ymin=',ymin write(4,*)'%xmax=',xmax write(4,*)'%ymax=',ymax c Set the number of contours to display write(6,*)' ' write(6,*)'Enter the number of contours to display' read*,nsteps write(4,*)'%nsteps=',nsteps y = ymin do 1 n = 0,nmax x = xmin do 2 m = 0,mmax u(m,n) = x*x - y*y x = x + dx 2 continue y = y + dy 1 continue do 3 n = 0,nmax write(4,100)(u(m,n),m=0,mmax) 3 continue 100 format(100f10.2) close(4) end
Compile and run Code 2, then experiment with different choices of values for contstyle and number of contours.

Click here to have plotmtv plot contours.

Figure 2 shows a traditional contour map of the function . It was created using the command line options -pfg BLACK -pbg GRAY. Use the 2D/3D toggle, (left click in the box 2D Plot or 3D Plot) to view a stacked contour map of this function. It does not appear to be possible to change the color of contour lines using the present version of plotmtv.

Figure 3 shows a 2D raster map representation of the function . It was created using the command line options -pfg BLACK -pbg WHITE. Again, use the 2D/3D toggle to view a colored surface map of the function. In 3D display mode both the height of the surface and the color of the surface represent the value of the function at a given point. While in 3D mode, left click on the boxes labeled Left, Right, Up and Down to obtain different views of the data set.

Figure 4 provides a wire frame surface plot of the function . As with Figure 3, the plot can be rotated and tilted to obtain different viewpoints. Use the toggle Wire Frame/Hidden Lines to switch between a wire frame display and an opaque surface display.