contour plot

Iain B. Findleton posted to comp.lang.tcl:

"Filled contour plots of irregularly spaced values proceeds usually by drawing the contour lines and then doing a flood fill. Drawing the contour lines proceeds by curve follower code (messy, difficult and not generally reliable), or by interpollation using Parzen estimators. There are packages out there that will do this stuff. If you want to do it on a canvas, I think you will find it slow if you implement in pure Tcl. Back in the 80's someone posted a neat algorithm for doing this called "incplot". It used interpolation applied to a scan line to draw the contours. It used really little CPU. I was able to implement it on an 8088 and draw weather maps with reasonable speed. A web search, or a literature search of PC Magazine arricles from the early 80s should find it for you. Unfortunately, it has evaporated from my machine.

A final alternative is to use a rendering algorithm to fit a surface to the points, and using a coloring algorithm to color the surface. OpenGL will do it, as will ray tracing codes and there are some 2D subroutines out there as well"


MBS With the help of AM, we have added contouring functionality to the plotchart module in tklib.

This means it is now possible to draw shaded contour maps and isolines in both 2D and 3D plots.

http://members.cox.net/mstucky5/images/sample.jpg

The data for these maps are supposed to lie on a structured 2D grid, but the coordinates of the grid points can be arbitrary (that is: it is not necessary to use rectangular grids).

The various methods are available in much the same way as with all plotchart methods:

Drawing contour maps (lines, filled/shaded, boxes):

$plot contourlines $xcrd $ycrd $values ?$classes?
$plot contourfill  ...
$plot contourbox ...

Setting the colour:

$plot colorMap $colors 

Underlying grid:

$plot grid $xcrd $ycrd

3D plots:

$plot plotfuncont $func $contours 

More details can be found in the documentation for the plotchart module.