Possible to put equation's expression near its graphic representation?

wolfram-mathematica

Solution

Using Mathematica 6 or higher, I often use Tooltip to help me identify plot curves:

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

Alas, this is only useful when using the graph interactively since you must hover the mouse cursor over the curve. It doesn't work so well on paper or on a static image.

You can use the Epilog option to manually place some text on the plot, as in this example:

Plot[
  Sin[x], {x, 0, 8 Pi},
  Epilog -> Text["My Text", Offset[{32, 0}, {14, Sin[14]}]]
]

Tweak the arguments of Offset to taste.

This works if you do not mind manual placement. Automatic placement poses some challenges, depending upon the kinds of functions that you wish to plot. But if you know something of the general characteristics of the functions of interest, you could write a function that calculates nice looking values for the Offset arguments. For example, if I knew I was going to plot lots of exponential decline functions, I might define something like the function myPlot in this example:

SetAttributes[myPlot, HoldAll]
myPlot[function_, {var_, min_, max_}] :=
  Plot[
    function, {var, min, max},
    Epilog -> Text[function, Offset[{40, 0}, {var, function} /. var -> min + (max - min)/20]],
    PlotRange -> All, AxesOrigin -> {0, 0}
  ]

... where the arguments to Offset are computed automatically using some arbitrary constants that work reasonably well for these kinds of plots:

Manipulate[
  myPlot[1000 E^(-d t), {t, 0, 100}, "My Label"],
  {d, 0.01, .2}
]

Since all of these options are programmable, the sky's limit as to how much sophistication you could code up for the label placement. Of course, such programming drifts farther and farther away from the ideal of a built-in option to Plot that just magically drops on some text next to the function. Mathematica 8 or 9 maybe :)

Problem

Is it possible that when I Plot a function in Mathematica, it will automatically put near it it's equation(i.e. y = 2x) or even some other text? At first glance I don't find any option for it, but if there is one I'd like to know. Thanks

Original source

Related problems