Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tooltips in ContourPlot

35 views
Skip to first unread message

David Park

unread,
Oct 2, 2007, 5:58:18 AM10/2/07
to
Is it possible to control what is displayed in Tooltips in contour plots?
For example, in the following plot:

ContourPlot[
Re[Cosh[x + \[ImaginaryI] y]] ==
Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}]

would it be possible to change the Tooltip to Re[Cosh[z]] == Re[Sin[z]] or
to some descriptive text?

--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

Syd Geraghty

unread,
Oct 3, 2007, 2:32:13 AM10/3/07
to
David,

I have had no luck after about 30 minutes scouring the documentation.

By analogy with Plot

Plot[Tooltip[Sin[x], "sine"], {x, 0, 10}]

should give you what you want but does not.

Try

ContourPlot[
Tooltip[Re[Cosh[x + I y]] == Re[Sin[x + I y]], "expr1==expr2"], {x,

-6,
6}, {y, -6, 6}]

for an unexpected result.


I hope someone comes up with an answer because tooltips documentation
for ContourPlot indicates that
it should work like tooltips for Graphics but it does not seem to.

Syd Geraghty B.Sc., M.Sc.
sydge...@mac.com
San Jose, CA

DrMajorBob

unread,
Oct 3, 2007, 2:34:15 AM10/3/07
to
Like this:

ContourPlot[
Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}] /.
Tooltip[x_, s_] :> Tooltip[x, "hello"]

There are eight Tooltip instances in the original plot, one for each line:

Cases[ContourPlot[


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}],
Tooltip[x_, s_] :> {Head@x, s}, Infinity]

{{Line, Re[Cosh[x + \[ImaginaryI] y]] ==
Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] ==

Re[Sin[x + \[ImaginaryI] y]]}, {Line,


Re[Cosh[x + \[ImaginaryI] y]] == Re[Sin[x + \[ImaginaryI] y]]}}

Bobby

On Tue, 02 Oct 2007 04:40:17 -0500, David Park <djm...@comcast.net> wrote:

> Is it possible to control what is displayed in Tooltips in contour plots?
> For example, in the following plot:
>
> ContourPlot[
> Re[Cosh[x + \[ImaginaryI] y]] ==
> Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}]
>
> would it be possible to change the Tooltip to Re[Cosh[z]] == Re[Sin[z]]
> or
> to some descriptive text?
>

--

DrMaj...@bigfoot.com

Carl Woll

unread,
Oct 3, 2007, 2:50:44 AM10/3/07
to
David Park wrote:

>Is it possible to control what is displayed in Tooltips in contour plots?
>For example, in the following plot:
>
>ContourPlot[
> Re[Cosh[x + \[ImaginaryI] y]] ==
> Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}]
>
>would it be possible to change the Tooltip to Re[Cosh[z]] == Re[Sin[z]] or
>to some descriptive text?
>
>
>

It doesn't seem as easy as I would have hoped. One possibility is to use
ReplaceAll:

ContourPlot[
Re[Cosh[x + I y]] == Re[Sin[x + I y]], {x, -6, 6}, {y, -6, 6}] /.
Tooltip[line_, lab_] :> Tooltip[line, Re[Cosh[z]] == Re[Sin[z]]]

Carl Woll
Wolfram Research

Gianluca Gorni

unread,
Oct 3, 2007, 6:32:49 AM10/3/07
to

There is one more problem with tooltips in ContourPlot in version 6.0.1.
If you give explicit Contours values that are not in
increasing order, the tooltips are wrong.
For example, the tooltips along the two contour lines

ContourPlot[x, {x, 0, 3}, {y, 0, 1}, Contours -> {2, 1}]

are reversed. The same for the ContourLabels:

ContourPlot[x, {x, 0, 3}, {y, 0, 1}, Contours -> {2, 1},
ContourLabels -> Automatic]

I suspect that ContourPlot internally sorts the Contours
into increasing order, but forgets about the sorting
when writing the labels and tooltips.

Gianluca Gorni

On 3 ott 2007, at 08:25, Syd Geraghty wrote:

> David,
>
> I have had no luck after about 30 minutes scouring the documentation.
>
> By analogy with Plot
>
> Plot[Tooltip[Sin[x], "sine"], {x, 0, 10}]
>
> should give you what you want but does not.
>
> Try
>
> ContourPlot[

> Tooltip[Re[Cosh[x + I y]] == Re[Sin[x + I y]], "expr1==expr2"], {x,


> -6,
> 6}, {y, -6, 6}]
>

> for an unexpected result.
>
>
> I hope someone comes up with an answer because tooltips documentation
> for ContourPlot indicates that
> it should work like tooltips for Graphics but it does not seem to.
>
> Syd Geraghty B.Sc., M.Sc.
> sydge...@mac.com
> San Jose, CA
>

> On Oct 2, 2007, at 2:40 AM, David Park wrote:
>
>> Is it possible to control what is displayed in Tooltips in contour
>> plots?
>> For example, in the following plot:
>>
>> ContourPlot[
>> Re[Cosh[x + \[ImaginaryI] y]] ==
>> Re[Sin[x + \[ImaginaryI] y]], {x, -6, 6}, {y, -6, 6}]
>>
>> would it be possible to change the Tooltip to Re[Cosh[z]] == Re[Sin
>> [z]] or
>> to some descriptive text?
>>

DrMajorBob

unread,
Oct 4, 2007, 4:30:00 AM10/4/07
to
For another surprise (to me, anyway), try

cp = ContourPlot[


Tooltip[Re[Cosh[x + I y]] == Re[Sin[x + I y]],

"expr1==expr2"], {x, -6, 6}, {y, -6, 6}];
Cases[cp, _Tooltip, Infinity]

You'll see a List of Line (not Tooltip) objects, but mousing over them
you'll see Tooltip values.

Each Line argument is a list of 4 to 5-digit integers, not pairs of reals
between -6 and 6. These are the integer coordinates mentioned in docs for
GraphicsComplex... an integer for each pixel pair position, or something
like that.

A little sleuthing reveals the meaning of the Tooltips:

cosh[{x_, y_}] = Re[Cosh[x + I y]];
sin[{x_, y_}] = Re[Sin[x + I y]];

Cases[Normal@cp,
Tooltip[Line[pts_], _] :> Mean[sin /@ pts - cosh /@ pts], Infinity]

{-99.9809, -99.9585, -99.9876, -99.9933, -99.9806, -99.9628, \
-99.9742, -99.9859, -49.9336, -49.9866, -49.954, -49.9861, -49.9959, \
-49.9675, -49.9887, -49.9845, 0.000421893, 0.0288174, 0.000155635, \
0.0337384, 0.000478683, 0.000501818, 0.00087235, 0.00470766, 49.9949, \
49.9944, 49.9797, 50.0086, 50.0067, 49.9776, 49.9867, 49.991, \
99.9719, 99.9705, 99.9789, 99.9842, 99.9602, 99.9793, 99.975, \
99.9726, 150., 149.978, 150.014, 149.968, 149.964, 149.979, 149.978, \
149.974, 200.003, 199.979}

Cases[Normal@cp,
Tooltip[Line[pts_], _] :>
Variance[sin /@ pts - cosh /@ pts], Infinity]

{0.0303026, 0.0131712, 0.0147298, 0.0129718, 0.00911339, 0.0283497, \
0.0072773, 0.0059341, 0.0161148, 0.00872554, 0.0154022, 0.00759067, \
0.00581582, 0.00918541, 0.00552482, 0.0116748, 0.00109861, 0.0205724, \
0.00574259, 0.0220134, 0.0039621, 0.00109243, 0.00330027, 0.0036575, \
0.00533634, 0.0111515, 0.010219, 0.0114676, 0.0135777, 0.0195418, \
0.0079861, 0.00711254, 0.00709383, 0.0215884, 0.00628416, 0.00685311, \
0.0144257, 0.00924261, 0.00888654, 0.0219085, 0.0112233, 0.00559716, \
0.0134408, 0.0145944, 0.0118609, 0.0091532, 0.0126382, 0.00683607, \
0.00679395, 0.00326373}

So the Tooltip values are differences between the LHS and RHS of the
original equation.

Most of the contour lines are NOT solutions of the equation, obviously,
and they're very approximate contours, as well. Eliminating Tooltip from
the argument and setting MaxRecursion gives more accurate contours and
eliminates those that don't solve the equation:

cp1 = ContourPlot[
Re[Cosh[x + I y]] == Re[Sin[x + I y]], {x, -6, 6}, {y, -6, 6},
MaxRecursion -> 5]
Cases[Normal@cp1,
Tooltip[Line[pts_], _] :> Mean[sin /@ pts - cosh /@ pts], Infinity]
Cases[Normal@cp1,
Tooltip[Line[pts_], _] :>
Variance[sin /@ pts - cosh /@ pts], Infinity]

Bobby

On Wed, 03 Oct 2007 01:25:16 -0500, Syd Geraghty <sydge...@mac.com>
wrote:

--

DrMaj...@bigfoot.com

0 new messages