Message Boards Message Boards

Automatic label on lines

Posted 10 years ago

If I use the function ContourPlot, eg

ContourPlot[y == x, {x, -1, 1}, {y, -1, 1}]

when I put the mouse on the line, it the equation "y==x" appears.

This does not happen with the Plot function.

Is there some way to obtain a similar behaviour also with the Plot function?

Thanks a lot :)

POSTED BY: g p
7 Replies

I think that I see what you mean. The Tooltip isn't transparent in the sense that you can see through it to whatever is behind it (the Sin[x] plot in your example). Instead, it seems to take one the background color of the stylesheet. Somebody else will have to chime in as I don't know how to make that work.

POSTED BY: Tim Mayes

Did you want a transparent background for the plot, or the Tooltip? The above only affects the Tooltip. If you want a transparent background for the plot, add this as an option (outside of the Tooltip)

Background -> Transparent

For example:

Plot[Tooltip[Sin[x], Sin[x], 
  TooltipStyle -> {Background -> Transparent}, 
  Background -> Transparent], {x, 0, 2 Pi}]
POSTED BY: Tim Mayes
Posted 10 years ago

In the example, the plot is the tooltip; I tried with

Tooltip["the transparent tooltip", 
 Plot[x, {x, 0, 1}, Background -> Transparent], 
 TooltipStyle -> {Background -> Transparent}]

but seems it doesn't work... I attach an immage

enter image description here

POSTED BY: g p
TooltipStyle -> {Background -> Transparent} 

seems to work. With None, I was getting a black background for some reason.

POSTED BY: Tim Mayes
Posted 10 years ago

Mmmh I tried your suggestion, but it gives me the same output: a plot with a white background!

enter image description here

POSTED BY: g p
Posted 10 years ago

Tooltip is what i was looking for!! Many many thanks :)

P.S. By the way, I read the Tooltip documentation and the Neat Example

Tooltip["the transparent tooltip", Plot[x, {x, 0, 1}], 
 TooltipStyle -> {Background -> None}]

doesn't give me a transparent tooltip, but one with white background...

POSTED BY: g p

How about something like this:

Plot[Tooltip[Sin[x], Sin[x]], {x, 0, 2 Pi}]

Using Tooltip you can specify the label just like in your ContourPlot.

POSTED BY: Tim Mayes
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract