MathGroup Archive 2010

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

Search the Archive

Re: Custom ContourLabels in Contour Plots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110266] Re: Custom ContourLabels in Contour Plots
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 11 Jun 2010 02:08:26 -0400 (EDT)
  • References: <hm56ku$k47$1@smc.vnet.net> <17652030.1276184119509.JavaMail.root@n11>

I don't recall if I ever got an answer to that specific question. There was
a change in the way ContourLabels works in Version 6 (or maybe 7) so you now
use:

ContourLabels -> Automatic for contour labels in tooltips only and
ContourLabels -> True for explicit "printed" contour labels but no tooltips.

But I'm not certain how you get both with plain Mathematica.

With the Presentations package there is a DrawLineLabels routine that will
place explicit contour labels on contour lines (and lines in any 2D plot
that have a function of constant value on the line). So there you could draw
the contour plot with ContourLabels -> Automatic to get tooltips, and then
use DrawLineLabels to explicitly label the contours, or even a selected
subset of contours.

Another quirk of contour labeling is that if you generate a set of contours
by using a Table or Range, say,

Range[-1, 1, 0.2]

you may get a nonzero "zero" value and an ugly label. I suggested to WRI
that since an approximate zero might be a common case they use Chop on label
values, but they thought it is better not to, so you have to do it yourself.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/ 



From: Istv=E1n Zachar [mailto:zac at freemail.hu]

I am interested in the solution as well! It seems so that this
functionality exists only in theory (the documentation) but not in the
field...
Istvan


On Feb 25, 8:51 am, "David Park" <djmp... at comcast.net> wrote:
> I would like to specify custom contour labels in Tooltips for contour
plot.
>
> ContourLabelshas a form {f, g} where f gives an explicit displayed label,
> and g gives a Tooltip for each complete contour. But I can't make this
form
> work and the Help has no explicit example of this form.
>
> Here is an example of what I would like to do:
>
> ContourPlot[Sin[x y] == 1/2, {x, 0, \[Pi]}, {y, 0, \[Pi]},
>
>  ContourLabels->
>
>   {Function[{x, y, z}, Text["", {x, y}]],
>
>    Function[{x, y, z}, Text["My Label"]]}
>
>  ]  
>
> No tooltips on the contours. I've tried a number of variations but nothing
> works. Neither does it work on a regular ContourPlot.
>
> ContourPlot[Sin[x y], {x, 0, \[Pi]}, {y, 0, \[Pi]},
>
>  Contours -> 5,
>
>  ContourLabels->
>
>   {Function[{x, y, z}, Text["", {x, y}]],
>
>    Function[{x, y, z}, Tooltip["My Label"]]}
>
>  ]  
>
> Does anyone know how to do this?
>
> David Park
>
> djmp... at comcast.net
>
> 
 <http://home.comcast.net/~djmpark>http://home.comcast.net/~djmpark/




  • Prev by Date: Re: why does CopyFile choke on transparently encrypted files?
  • Next by Date: Re: Mac OS X hard disk space used up by virtual
  • Previous by thread: Re: Custom ContourLabels in Contour Plots
  • Next by thread: 3D plot of hemisphere pushing into a triangular membrane or surface