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

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

问题描述

如何分别标记每行:

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

推荐答案

有一些不错的代码,可以让您在如何在ListPlots中对多个数据集进行注释的答案 /a>.

There's some nice code that allows you to do this dynamically in an answer to How to annotate multiple datasets in ListPlots.

技术说明图形标签曲线

当然,如果您没有太多图像要制作, 那么使用 Epilog 手动添加标签就不难了例子

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天全站免登陆