Wolfram mathematica Mathematica中的Plotlegend不适用于函数表

Wolfram mathematica Mathematica中的Plotlegend不适用于函数表,wolfram-mathematica,plot,Wolfram Mathematica,Plot,我正在尝试使用Mathematica v8中的PlotLegend绘制带有图例的函数列表。作为一个简单的测试来说明我在做什么 <<PlotLegends` test = Table[f[x], {f, {Sin, Cos, Tan, Log, Exp}}] Plot[test, {x, 0, 1}, PlotRange -> Full, Axes -> {True, False}, PlotStyle -> Thick, AxesOrigin -> {0,

我正在尝试使用Mathematica v8中的PlotLegend绘制带有图例的函数列表。作为一个简单的测试来说明我在做什么

<<PlotLegends`
test = Table[f[x], {f, {Sin, Cos, Tan, Log, Exp}}]
Plot[test, {x, 0, 1}, PlotRange -> Full, Axes -> {True, False}, 
PlotStyle -> Thick, AxesOrigin -> {0, 0}, 
PlotLegend -> {"Sin", "Cos", "Tan", "Log", "Exp"}, 
LegendPosition -> {0, -0.5}, LegendShadow -> None]

但是,如果我显式地将表放入Plot命令中,则会得到正确的图例

Plot[{Sin[x], Cos[x], Tan[x], Log[x], Exp[x]}, {x, 0, 1}, 
PlotRange -> Full, Axes -> {True, False}, PlotStyle -> Thick, 
AxesOrigin -> {0, 0}, 
PlotLegend -> {"Sin", "Cos", "Tan", "Log", "Exp"}, 
LegendPosition -> {0, -0.5}, LegendShadow -> None] 

对于我的实际应用程序,我将在Do循环中列出一系列函数,因此后一个Plot命令并不理想

如有任何建议,将不胜感激

干杯,
Mike

绘图[测试,…]
替换为
绘图[Evaluate@test,…]


问题是Plot接受未计算的第一个参数,并且仅在计算点时计算它。因此,当它确定标签时,它只看到一个参数
test
,而不是一个列表,因此它只输出一个标签<代码>Evaluate@test告诉Mathematica在将其传递到
绘图
之前,先对
测试进行求值,即使
绘图
被定义为未求值的参数。这样,Plot会看到存储在
test
中的列表,并知道如何生成多个标签。

Plot替换
Plot[test,…]
[Evaluate@test,…]


问题是Plot接受未计算的第一个参数,并且仅在计算点时计算它。因此,当它确定标签时,它只看到一个参数
test
,而不是一个列表,因此它只输出一个标签<代码>Evaluate@test
告诉Mathematica在将其传递到
绘图
之前,先对
测试进行求值,即使
绘图
被定义为未求值的参数。这样,Plot会看到存储在
test
中的列表,并知道如何生成多个标签。

Plot[Evaluate@test,…]
帮助?谢谢。这就是诀窍。
绘图吗[Evaluate@test,…]
帮助?谢谢。这就是诀窍。
Plot[{Sin[x], Cos[x], Tan[x], Log[x], Exp[x]}, {x, 0, 1}, 
PlotRange -> Full, Axes -> {True, False}, PlotStyle -> Thick, 
AxesOrigin -> {0, 0}, 
PlotLegend -> {"Sin", "Cos", "Tan", "Log", "Exp"}, 
LegendPosition -> {0, -0.5}, LegendShadow -> None]