MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

LabelContourLines bug/feature

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38384] LabelContourLines bug/feature
  • From: Martin Johansson <martin.n.johansson at emw.ericsson.se>
  • Date: Fri, 13 Dec 2002 04:09:58 -0500 (EST)
  • Organization: Ericsson Microwave Systems AB
  • Sender: owner-wri-mathgroup at wolfram.com

Hi!

I'm using the function LabelContourLines from  Tom Wickham-Jones'
ExtendGraphics package and I've been having some problems getting
the proper labels on the contours. I have found a workaround,
but it would still be interesting to see other possible solutions
to the problem.

Load the part of the package that we need:

  << ExtendGraphics`LabelContour`

Make a trivial contour plot: 

  c1 = ContourPlot[x, {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
        Contours -> Range[-3, 3, 1], PlotRange -> All];

This generates a contour plot with "vertical" lines
at  x = {-2, -1, 0, 1, 2}, i.e., five lines.

Put labels on the contours:

  LabelContourLines[c1];

This puts labels {-3, -2, -1, 0, 1} on the vertical lines
described above, i.e., the labels start with the lowest value
defined in the option statement "Contours -> Range[-3, 3, 1]"
"Obviously", this is not what I wanted. It seems that
LabelContourLines always uses the first value of Contours
for the label of the contour line with the lowest value,
and so on for increasing values, regardless of the range
of values actually shown in the plot.

My desired behavior would be to label each line according
to its value. This quick fix (?) appears to produce what
I want (edit in LabelContour.m):

(* FindContours[ x_List, {z1_, z2_}] := x  Original version *)
   
   FindContours[ x_List, {z1_, z2_}] :=
   Table[If[z1 <= x[[m]] <= z2, x[[m]] , {}],{m,Length[x]}]//Flatten

It simply uses the full z-range of the contour plot
to remove those contour values (as specified in Contours -> ...)
that fall outside the range.

Any comments on this? Is there a way to get the original code
to put "proper" labels on corresponding contour lines?
Is there a better (more efficient) way of fixing "the problem"?

TIA,

Martin


  • Prev by Date: Re: Nonlinear Fit
  • Next by Date: Numeric Integration of Tabulated Integrand Function: Part I
  • Previous by thread: Re: Programming language difficulties.
  • Next by thread: RE: LabelContourLines bug/feature