可以将方程的表达式放在其图形表示附近吗? [英] Possible to put equation's expression near its graphic representation?

查看:17
本文介绍了可以将方程的表达式放在其图形表示附近吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能当我在 Mathematica 中绘制一个函数时,它会自动将它的方程(即 y = 2x)或其他一些文本放在它附近?

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.

谢谢

推荐答案

使用 Mathematica 6 或更高版本,我经常使用 Tooltip 来帮助我识别绘图曲线:

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.

您可以使用 Epilog 选项手动在绘图上放置一些文本,如下例所示:

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

根据口味调整 Offset 的参数.

Tweak the arguments of Offset to taste.

如果您不介意手动放置,这会起作用.自动放置会带来一些挑战,具体取决于您希望绘制的函数类型.但是,如果您对感兴趣的函数的一般特征有所了解,则可以编写一个函数来计算 Offset 参数的漂亮值.例如,如果我知道我要绘制许多指数递减函数,我可能会在这个例子中定义类似函数 myPlot 的东西:

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

... 其中 Offset 的参数是使用一些任意常数自动计算的,这些常数对于这些类型的图工作得相当好:

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

由于所有这些选项都是可编程的,因此您可以为标签放置编码的复杂程度是无限的.当然,这样的编程离Plot 的内置选项的理想越来越远,它只是神奇地落在函数旁边的一些文本上.Mathematica 8 或 9 可能:)

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

这篇关于可以将方程的表达式放在其图形表示附近吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆