[S] Redundant lines in contour()

Patrick Connolly (PConnolly@grunt.marc.cri.nz)
Fri, 3 Jul 1998 15:17:41 +1200 (NZST)


Whenever I use contour() to calculate contour lines, I invariably find
at least one line that will be labelled twice, which adds unnecessary
verbiage (or is it numerage?) to the plot. Examination of the list
returned by contour(... , save = T) will show occasional NAs in both
the x and y vectors, e.g.

$x:
[1] 5.298317 5.176043 5.053768 4.931493 4.809218 4.686944 4.564669 4.442394
[9] 4.367046 4.320119 4.197845 4.075570 3.953295 3.901239 3.831020 3.708745
[17] 3.586470 3.510794 3.464195 3.341921 3.219646 3.178792 3.097371 2.975096
[25] 2.893024 2.852822 2.730547 2.644462 2.608272 2.485997 2.426283 2.363723
[33] 2.241448 2.233237 2.119173 2.061218 1.996898 1.906968 1.874623 1.767869
[41] 1.752349 1.641794 1.630074 1.526994 1.507799 1.422022 1.385524 1.325668
[49] 1.263249 1.236913 1.154891 1.140975 1.078865 1.018700 1.008199 0.942348
[57] 0.896425 0.880834 0.823242 0.774150 0.769210 0.718418 0.670581 0.651875
[65] 0.625450 0.582802 0.542436 0.529601 0.504175 0.467858 0.433341 0.407326
[73] 0.400492 0.369195 0.339341 0.310833 NA 4.932366 4.931493 NA

$y:
[1] 7.136485 7.230182 7.327711 7.429312 7.535246 7.645796 7.761271
[8] 7.882006 7.959184 8.008370 8.140766 8.279637 8.425468 8.489796
[15] 8.578798 8.740219 8.910390 9.020409 9.090041 9.279988 9.481141
[22] 9.551021 9.694523 9.921284 10.081633 10.162722 10.420310 10.612245
[29] 10.695725 10.990886 11.142858 11.307991 11.649584 11.673470 12.018616
[36] 12.204082 12.418530 12.734694 12.853374 13.265306 13.327931 13.795918
[43] 13.847904 14.326530 14.420137 14.857142 15.052929 15.387755 15.756428
[50] 15.918367 16.448980 16.543188 16.979591 17.428917 17.510204 18.040817
[57] 18.433548 18.571428 19.102041 19.582739 19.632652 20.163265 20.693878
[64] 20.910118 21.224489 21.755102 22.285715 22.460608 22.816326 23.346939
[71] 23.877550 24.295622 24.408163 24.938776 25.469387 26.000000 NA
[78] 7.428571 7.429312 NA

At first I thought numbers were being repeated, so I thought it would
be simple enough to eliminate duplicates. But in this example, the
79th elements are repeats of the 4th elements, but the 78ths are
unique in their respective vectors. As someone once said: "Life
wasn't meant to be easy."

Foolishly imagining that it was one of the bugs that was being sorted
out, I didn't try very hard to work out what was happening. I could have
tried removing NAs, but I could imagine horrendous complications on
the occasions when there really was more than one line of a particular
level.

However, I did devise a simple, though not very elegant plan which
others might find useful in the absence of something better. Instead
of specifying a level of say, 10 (which was known to produce duplicate
labels in this example), my approach is to specify 10.01 which does
not produce a phantom line, but will of course mess up the contour
plot. UNTIL, that is, I edit the postscript file, and change the
10.01 label back to 10. "10.01" is fairly distinctive in a postscript
file, whereas "10" is not. Postscript fortuitously recentres the text
used to indicate the level of the contour line, so there is no
alignment problem.

Any better ideas gladly considered.

Share and enjoy!

Patrick

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news