Automatic label on lines

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 :slight_smile:

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.

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

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…

TooltipStyle → {Background → Transparent}

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

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

enter image description here

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}]

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

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.