## Re: Contour plots

 Re: Contour plots From: Daniel J Sebald - 2005-01-28 09:15:02 ```Hans-Bernhard Broeker wrote: > Daniel J Sebald wrote: > > [...] > >> I would too. However, might it be possible to use some simple >> algorithm that does an OK job in most cases? > > > I rather much doubt that such a thing exists. In contouring, I suspect > most cases are too tricky for any simple algorithm. I suppose. With a straight line you could cover ovals. (Annotation only for ovals! That'd go over big.) >> The worst case scenario is when the contours are rather small oval >> shapes, or rather close together. But if it is unacceptable to the >> user, then he or she could turn off annotation. > > > We really need better control than just on/off on this. > >> Rather than an optimization problem where we, say, pick a trajectory >> with the smallest gradient (i.e., largest spacing between contours), >> could we just pick some line for which to intersect as the spot to >> pick the label text? (Intersecting with lines is a not so difficult >> thing.) > > > A line (without ends other than where it leaves the graph box) would not > be a good idea. It has to be a line segment, and probably an > optionally curved one at that. Which raises a serious problem about the > command-line user interface we could provide to specify such a thing. > > >> The contour plot algorithm apparently already knows how to create the >> contours and whether they are lines or closed curves. So, if it is >> a closed curve, pick the starting point or some other rule. > > > If it's closed, it doesn't really have a starting point, does it? Not mathematically, but in the plotting routine it has to start somewhere. But I'm sure the starting point for drawing the curve isn't necessarily the best position. > >> If it is an open curve, take the line that bisects the endpoints and >> find where that intersects the curve. > > > No way. The number of intersections can easily be zero, or could be > a dozen. I meant take the two end points and halfway between them strike a line perpendicular to the line connecting them. That has to intersect the curve at at least one point. Could be more. Pick the first one. What one would do is store the perpendicular line as a hyperplane. Then as constructing the level curve one segment at a time, apply the position of the segment end points to the hyperplane. If the sign changes there is an intersection. Closed curves would be a different issue. Maybe search for the extremal x/y points and draw a line through the corners... I don't know, starting to ramble. Of course, the optimum thing to do is to pick the location on the level curve that is furthest from it's neighboring level curves. It has to work on general data, so gradient or such would be out. Is there a way to compute such a thing while drawing contour segments? Dan ```