当鼠标光标在 Wolfram|Alpha 中的 2D 绘图上时,会出现一对灰线,帮助您读取 x 和 y 轴的坐标 .
For example ,我将鼠标悬停在以下 Airy 函数图中的转折点之一上。
上述内容也可以在 Mathematica 中使用
WolframAlpha["Plot Ai(x)", {{"Plot", 1}, "Content"}]
它具有某种定位器的附加优势,可以显示坐标 .
如何在普通的 Mathematica 图形/绘图中模拟这种行为?
最佳答案
这是您在评论中要求的功能之一:
locatorPlot[func_, r : {var_, __}, other___] :=
LocatorPane[
Dynamic[pos, (pos = {#, func /. var -> #}) & @@ # &],
Column[{Plot[func, r, other], Dynamic@pos}],
AutoAction -> True,
Appearance ->
Graphics[{Gray, Line @ {{{-1, 0}, {1, 0}}, {{0, -1}, {0, 1}}}},
ImageSize -> Full]
]
locatorPlot[AiryAi[z], {z, -11, 5}, ImageSize -> 400]
这是一个相当笨重的更新来处理您的新请求:
locatorPlot[func_List, r : {var_, __}, other___] :=
DynamicModule[{pos, pos2},
LocatorPane[
Dynamic[pos, (pos = #; (pos2 = {#, First@Nearest[func /. var -> #, #2]}) & @@ #) &],
Plot[func, r, other,
Epilog ->
{Text[\[GrayCircle], Dynamic@pos2], Text[Dynamic@pos2, Dynamic@pos2, {-1.2, 0}]}
],
AutoAction -> True,
Appearance ->
Graphics[{Gray, Line@{{{-1, 0}, {1, 0}}, {{0, -1}, {0, 1}}}}, ImageSize -> Full]
]
]
locatorPlot[{AiryAi[z], Sin[z]}, {z, -11, 5}, ImageSize -> 400]
关于wolfram-mathematica - 如何在 Mathematica 中获得 Wolfram|Alpha 2D 图形的十字准线行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8222733/