Mar*_*lig 9 wolfram-mathematica
我经常不得不同时可视化多个数据集,一般在ListPlot或它的日志 - 同伴.由于数据集的数量通常大于容易区分的线条样式的数量,并且创建大型情节传说仍然有点不明显,我仍然在寻找一种在我的图中注释不同线条/集合的好方法.提示在屏幕上工作时不错,但如果我需要pritn情节他们不帮助.
最近,我使用Mesh选项来枚举我的数据集,并发现了一些奇怪的东西
GraphicsGrid[Partition[Table[ListPlot[
Transpose@
Table[{Sin[x], Cos[x], Tan[x], Cot[x]}, {x, 0.01, 10, 0.1}],
PlotMarkers -> {"1", "2", "3", "4"}, Mesh -> i, Joined -> True,
PlotLabel -> "Mesh\[Rule]" <> ToString[i], ImageSize -> 180], {i,
1, 30}], 4]]
Run Code Online (Sandbox Code Playgroud)
结果在我的机器上看起来像这样(Windows 7 x64,Mathematica 8.0.1):

有趣的是,对于Mesh-> 2,8和10,结果看起来像我预期的,其余的没有.要么我不理解Mesh选项,要么它不理解我.
这是我的问题:
Chr*_*nen 12
你可以沿着这些方向尝试一些东西.将每一行设为一个按钮,单击该按钮即可识别自身.
plot=Plot[{Sin[x],Cos[x]},{x,0,2*Pi}];
sinline=plot[[1,1,3,2]];
cosline=plot[[1,1,4,2]];
message="";
altplot=Append[plot,PlotLabel->Dynamic[message]];
altplot[[1,1,3,2]]=Button[sinline,message="Clicked on the Sin line"];
altplot[[1,1,4,2]]=Button[cosline,message="Clicked on the Cos line"];
altplot
Run Code Online (Sandbox Code Playgroud)
如果添加EventHandler,则可以获取单击的位置,并将具有相关定位标签的Inset添加到绘图中.将绘图包裹在动态中,以便在每次单击按钮后自动更新.它工作正常.
在回应评论时,这是一个更全面的版本:
plot = Plot[{Sin[x], Cos[x]}, {x, 0, 2*Pi}];
sinline = plot[[1, 1, 3, 2]];
cosline = plot[[1, 1, 4, 2]];
AddLabel[label_] := (AppendTo[plot[[1]],
Inset[Framed[label, Background -> White], pt]];
(* Remove buttons for final plot *)
plainplot = plot;
plainplot[[1, 1, 3, 2]] = plainplot[[1, 1, 3, 2, 1]];
plainplot[[1, 1, 4, 2]] = plainplot[[1, 1, 4, 2, 1]]);
plot[[1, 1, 3, 2]] = Button[sinline, AddLabel["Sin"]];
plot[[1, 1, 4, 2]] = Button[cosline, AddLabel["Cos"]];
Dynamic[EventHandler[plot,
"MouseDown" :> (pt = MousePosition["Graphics"])]]
Run Code Online (Sandbox Code Playgroud)
要添加标签,请单击该行.设置为"plainplot"的最终带注释的图表是可打印和可复制的,不包含动态元素.
[当天晚些时候]另一个版本,这次是通用的,并且基于初始图表.(使用Mark McClure解决方案的部分.)对于不同的图,可以根据需要编辑'ff'和'spec'.
ff = {Sin, Cos, Tan, Cot};
spec = Range[0.1, 10, 0.1];
(* Plot functions separately to obtain line counts *)
plots = Array[ListLinePlot[ff[[#]] /@ spec] &, Length@ff];
plots = DeleteCases[plots, Line[_?(Length[#] < 3 &)], Infinity];
numlines = Array[Length@Cases[plots[[#]], Line[_], Infinity] &,
Length@ff];
(* Plot functions together for annotation plot *)
plot = ListLinePlot[#@spec & /@ ff];
plot = DeleteCases[plot, Line[_?(Length[#] < 3 &)], Infinity];
lbl = Flatten@Array[ConstantArray[ToString@ff[[#]],
numlines[[#]]] &, Length@ff];
(* Line positions to substitute with buttons *)
linepos = Position[plot, Line, Infinity];
Clear[line];
(* Copy all the lines to line[n] *)
Array[(line[#] = plot[[Sequence @@ Most@linepos[[#]]]]) &,
Total@numlines];
(* Button function *)
AddLabel[label_] := (AppendTo[plot[[1]],
Inset[Framed[label, Background -> White], pt]];
(* Remove buttons for final plain plot *)
plainplot = plot;
bpos = Position[plainplot, Button, Infinity];
Array[(plainplot[[Sequence @@ Most@bpos[[#]]]] =
plainplot[[Sequence @@ Append[Most@bpos[[#]], 1]]]) &,
Length@bpos]);
(* Substitute all the lines with line buttons *)
Array[(plot[[Sequence @@ Most@linepos[[#]]]] = Button[line[#],
AddLabel[lbl[[#]]]]) &, Total@numlines];
Dynamic[EventHandler[plot,
"MouseDown" :> (pt = MousePosition["Graphics"])]]
Run Code Online (Sandbox Code Playgroud)
这是它的外观.注释后,可以找到普通图形对象设置为'plainplot'变量.

一种方法是分别生成图,然后将它们一起显示.这样产生的代码比其他帖子更像你的代码,因为它PlotMarkers似乎与我们在处理一个数据集时的预期方式相同.我们可以使用得到同样的着色ColorData用PlotStyle.这是结果:
ff = {Sin, Cos, Tan, Cot};
plots = Table[ListLinePlot[ff[[i]] /@ Range[0.1, 10, 0.1],
PlotStyle -> {ColorData[1, i]},
PlotMarkers -> i, Mesh -> 22], {i, 1, Length[ff]}];
(* Delete the spurious asymptote looking thingies. *)
plots = DeleteCases[plots, Line[ll_?(Length[#] < 4 &)], Infinity];
Show[plots, PlotRange -> {-4, 4}]
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
3790 次 |
| 最近记录: |