如何在 Mathematica 中标记不同的曲线? [英] How do I label different curves in Mathematica?

查看:45
本文介绍了如何在 Mathematica 中标记不同的曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分别标记每一行:

Plot[{{5 + 2 x}, {6 + x}}, {x, 0, 10}]

推荐答案

如何在 ListPlots 中注释多个数据集的答案.

技术说明中还定义了一个 LabelPlot 命令标签图中的曲线

There's also a LabelPlot command defined in the Technical Note Labeling Curves in Plots

当然,如果你没有太多的图像要制作,那么在使用 Epilog<时手动添加标签并不难/a>,例如

Of course, if you don't have too many images to make, then it's not hard to manually add the labels in using Epilog, for example

fns[x_] := {5 + 2 x, 6 + x}; 
len := Length[fns[x]];

Plot[Evaluate[fns[x]], {x, 0, 10}, 
 Epilog -> Table[Inset[
    Framed[DisplayForm[fns[x][[i]]], RoundingRadius -> 5], 
    {5, fns[5][[i]]}, Background -> White], {i, len}]]

事实上,您可以使用 Locators 做类似的事情,让您可以将标签移动到您想要的任何位置:

In fact, you can do something similar with Locators that allows you to move the labels wherever you want:

DynamicModule[{pos = Table[{1, fns[1][[i]]}, {i, len}]},
 LocatorPane[Dynamic[pos], Plot[Evaluate[fns[x]], {x, 0, 10}],
  Appearance -> Table[Framed[Text@TraditionalForm[fns[x][[i]]], 
                  RoundingRadius -> 5, Background -> White], {i, len}]]]

在上面我让定位器采用标签的形式,尽管也可以像上面那样保留一个 Epilog 并有不可见的定位器来控制位置.定位器也可以被约束(使用 Dynamic 的第二个参数)到适当的曲线......但这并不是真正必要的.

In the above I made the locators take the form of the labels, although it is also possible to keep an Epilog like that above and have invisible locators that control the positions. The locators could also be constrained (using the 2nd argument of Dynamic) to the appropriate curves... but that's not really necessary.

作为上面代码的例子,带有手动移动标签的函数:

As an example of the above code with the functions with the labels moved by hand:

fns[x_] := {Log[x], Exp[x], Sin[x], Cos[x]};

这篇关于如何在 Mathematica 中标记不同的曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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