如何从绘制列表的名称中获取绘图标签?

时间:2014-01-31 23:46:58

标签: plot wolfram-mathematica mathematica-8

我有一个名为DataList的数据列表。我可以使用ListPlot绘制数据并在输入列表之后命名该绘图,如下所示:

  

ListPlot[DataList, PlotLabel -> ToString[HoldForm[DataList]]]

这很有效,我就像我想要的那样得到情节。但是我有很多数据列表,所以我为此目的编写了一个函数,使用以下内容:

  

plot[input_] := ListPlot[input, PlotLabel -> ToString[HoldForm[input]]]

但是,当我现在输入一个列表时,“PlotLabel”将不会反映我输入的列表的名称,而是反映该列表的内容。

有没有办法在函数求值之前提取列表/表达式的名称?

任何其他想法来解决这个问题?

我非常感谢任何提示。

1 个答案:

答案 0 :(得分:1)

DataList = {1, 2, 5, 4, 3, 7};
SetAttributes[plot, HoldFirst];
plot[input_] := ListPlot[input, PlotLabel -> ToString[Unevaluated[input]]];
plot[DataList]

...PlotWithPlotLabel  DataList  snipped...
相关问题