Here's my version that behaves similarly to the Wolfram|Alpha output, except for its handling of multiple plots. In the W|A graphics, the circle and the text jump to the nearest curve, and disappear completely when the cursor is not over the graphics.
It would be nice to add in the missing functionality and maybe make the code more flexible.
WAPlot[fns_, range : {var_Symbol, __}] :=
DynamicModule[{pos, fn = fns},
If[Head[fn] === List, fn = First[Flatten[fn]]];
LocatorPane[Dynamic[pos, (pos = {var, fn} /. var -> #[[1]]) &],
Plot[fns, range, Method -> {"GridLinesInFront" -> True},
GridLines->Dynamic[{{#,Gray}}&/@MousePosition[{"Graphics",Graphics},None]]],
AutoAction -> True,
Appearance -> Dynamic[Graphics[{Circle[pos, Scaled[.01]],
Text[Framed[Row[pos, ", "], RoundingRadius -> 5,
Background -> White], pos, {-1.3, 0}]}]]]]
Then, e.g.
WAPlot[{{AiryAi[x], -AiryAi[x]}, AiryBi[x]}, {x, -10, 2}]
Here's a new version that uses MousePosition
instead of LocatorPane
and steals Mr W's code to make the circle move to the nearest curve.
The behaviour is now almost identical to the WolframAlpha
output.
WAPlot[fns_, range : {var_Symbol, __}] :=
DynamicModule[{fnList = Flatten[{fns}]}, Plot[fnList, range,
GridLines ->
Dynamic[{{#, Gray}} & /@ MousePosition[{"Graphics", Graphics}]],
Method -> {"GridLinesInFront" -> True},
Epilog -> Dynamic[With[{mp = MousePosition[{"Graphics", Graphics}, None]},
If[mp === None, {},
With[{pos = {#1, First@Nearest[fnList /. var -> #1, #2]}& @@ mp},
{Text[Style["\[EmptyCircle]", Medium, Bold], pos],
Text[Style[NumberForm[Row[pos, ", "], 2], Medium], pos,
{If[First[MousePosition["GraphicsScaled"]] < .5, -1.3, 1.3], 0},
Background -> White]}]]]]
]]
The output looks very similar to the previous version so I won't post a screenshot.
InputForm
on the result fromWolframAlpha[..]
... – SchwarzwaldGridLines
from (used here). However, theInputForm
seems to have got a lot messier since then - I guess as they added more features and made it handle more cases... – DipteralExperimental`Explore[Plot]
. – Wingspread