La petite galerie du CRM
Links2Go
Applets |
Contour Plotting using Java
This page: 12 Kb. approx.
Yes, this page uses Java and thus requires a Java-enabled browser.
This is a work in progress.
|
Instructions
- Enter the matrix of z values, in the following format (similar to Mathematica format):
- The values are floating point numbers separated by commas.
- Each row of values is enclosed in brace brackets.
e.g. {0.4, 1.2, 1.03}
- The rows themselves are separated by commas and enclosed in brace brackets.
- The number of rows must be at least 2 and at most 100.
- The rows need not be of the same length; the longest row must have at least 2 and at most 100 values.
- Click in the button "Draw" to trace the contour plot based on the data you have provided. The program will:
- parse the matrix of z values, filling short rows with zeroes if necessary to make the matrix rectangular;
- calculate ten values, one for each contour to be drawn, by linearly interpolating between the maximum and minimum z values in the matrix;
(One may, however, select logarithmic interpolation using the check box just to the left of the "Draw" button.
Log interpolation is better for data containing sharp peaks, but is possible only if all values in the matrix are positive.)
- display the results of steps 1 and 2 (including the 10 contour values, numbered [0] through [9]) in the area in the lower left of the applet's panel; and
- draw the contour plot in the right-hand portion of the applet's panel.
About this applet...
This applet is a work in progress. It was developed by
David Rand on a Macintosh using Metrowerks CodeWarrior Java.
It has undergone preliminary testing on Macintosh and UNIX platforms. If you experience problems with this applet, please inform
the author by e-mail at rand@CRM.UMontreal.CA; be sure to specify your platform and browser.
Thanks in advance.
The plotting algorithm was taken from a Fortran program by Snyder [1]. The program was first translated into C,
then reworked, and finally translated into Java. Flanagan [2] was indispensable for the Java implementation.
A feature article [3] describing this applet has been published in MacTech magazine.
You may download the complete Java source code as a compressed archive from
MacTech's web site. You may also access the Java source code as plain text directly
on this site.
References
- W. V. Snyder, "Algorithm 531, Contour plotting [J6]",
ACM Trans. Math. Softw. 4, 3 (Sept. 1978), 290-294.
- D. Flanagan, Java in a Nutshell, O'Reilly & Associates (1996).
- David Rand, "Contour plotting in Java",
MacTech magazine 13, 9 (Sept. 1997), 14-28.
Table of Contents of "La petite galerie du CRM"
5 November 1998, webmaster@CRM.UMontreal.CA