Contour Plots

A routine is available in PLPLOT which performs a contour plot of data stored in a two-dimensional array. A contour following algorithm is used, so that it is possible to use non-continuous line styles.

The routine <#1094#>plcont<#1094#> (page #plcont#1095>) has the form
#ename1096#
where <#999#>z<#999#> is the two-dimensional array of size #math28##tex2html_wrap_inline5378#×#tex2html_wrap_inline5379# containing samples of the function to be contoured. The parameters <#1002#>kx<#1002#>, <#1003#>lx<#1003#>, <#1004#>ky<#1004#> and <#1005#>ly<#1005#> specify the portion of <#1006#>z<#1006#> that is to be considered. The array <#1007#>clevel<#1007#> of length <#1008#>nlevel<#1008#> is a list of the desired contour levels.

The path of each contour is initially computed in terms of the values of the array indicies which range from 1 to <#1009#>nx<#1009#> in the first index and from 1 to <#1010#>ny<#1010#> in the second index. Before these can be drawn in the current window (see page #window#1011> in Section #window#1012>), it is necessary to convert from these array indicies into world coordinates. This is done by passing a pointer to a user-defined function to <#1013#>plcont<#1013#>. This function pointer is the last argument <#1014#>tr<#1014#>. This function must be declared as type <#1015#>void<#1015#> in the module which calls <#1016#>plcont<#1016#>. This transformation function must have the parameter list
#ename1099#
where <#1018#>(x,y)<#1018#> is the point through which the contour runs expressed in terms of array indicies, and <#1019#>(tx,ty)<#1019#> are pointers to float variables which are the world coordinates of the point which corresponds to these indicies.

Often, the transformation between array indicies and world coordinates can be expressed as a linear transformation. A routine is provided within the library which can be passed to <#1020#>plcont<#1020#> as the parameter <#1021#>tr<#1021#>. This transformation routine is as follows:

verbatim15#
Thus by setting up the values in the array <#1024#>tr[]<#1024#>, we can apply an arbitrary translation, rotation and/or shear to the array before drawing out the contours. By defining other transformation subroutines, it is possible to draw contours wrapped around polar grids etc.

As an example in setting up <#1025#>tr[]<#1025#>, suppose that the array <#1026#>z<#1026#> is of size #math29#21×41 and contains the values of the function z[x][y], where x ranges from 0.0 to 4.0 and y ranges from -8.0 to 8.0. Furthermore, let us also suppose that the window (as defined using <#1027#>plenv<#1027#> or <#1028#>plwind<#1028#>) covers this range of world coordinates. Since we wish the index (1,1) in array <#1029#>z<#1029#> to map to (0.0,-8.0) and the index (21,41) to map to (4.0,8.0), and for there to be no skew in the axes, we should choose elements of <#1030#>tr[]<#1030#> so that

#math30#

tx ;SPMnbsp;=;SPMnbsp; 
ty ;SPMnbsp;=;SPMnbsp; 

and so <#1034#>tr[0]=0.2<#1034#>, <#1035#>tr[1]=0.0<#1035#>, <#1036#>tr[2]=-0.2<#1036#>, <#1037#>tr[3]=0.0<#1037#>, <#1038#>tr[4]=0.4<#1038#>, <#1039#>tr[5]=-8.4<#1039#>. #./chapter3.tex# #./chapter4.tex#