Bạn có thể thử điều gì đó dọc theo các dòng này. Đặt mỗi dòng thành một nút, khi được nhấp, sẽ tự xác định.
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
Nếu bạn thêm EventHandler, bạn có thể nhận vị trí mà bạn đã nhấp và thêm Inset với nhãn vị trí có liên quan vào ô. Quấn cốt truyện vào một Dynamic để nó tự cập nhật sau mỗi lần nhấn nút. Nó hoạt động tốt.
Để đối phó với các ý kiến, đây là một phiên bản đầy đủ:
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"])]]
Để thêm một nhấp chuột nhãn trên đường dây. Biểu đồ chú thích cuối cùng, được đặt thành 'plainplot', có thể in và có thể sao chép và không chứa các phần tử động.
[Sau đó trong ngày] Một phiên bản khác, lần này là chung chung và dựa trên biểu đồ ban đầu. (Với các phần của giải pháp Mark McClure được sử dụng.) Đối với các lô khác nhau 'ff' và 'spec' có thể được chỉnh sửa như mong muốn.
ff = {Sin, Cos, Tan, Cot};
spec = Range[0.1, 10, 0.1];
(* Plot functions separately to obtain line counts *)
plots = Array[ListLinePlot[ff[[#]] /@ spec] &, [email protected]];
plots = DeleteCases[plots, Line[_?(Length[#] < 3 &)], Infinity];
numlines = Array[[email protected][plots[[#]], Line[_], Infinity] &,
[email protected]];
(* Plot functions together for annotation plot *)
plot = ListLinePlot[#@spec & /@ ff];
plot = DeleteCases[plot, Line[_?(Length[#] < 3 &)], Infinity];
lbl = [email protected][ConstantArray[[email protected][[#]],
numlines[[#]]] &, [email protected]];
(* Line positions to substitute with buttons *)
linepos = Position[plot, Line, Infinity];
Clear[line];
(* Copy all the lines to line[n] *)
Array[(line[#] = plot[[Sequence @@ [email protected][[#]]]]) &,
[email protected]];
(* 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 @@ [email protected][[#]]]] =
plainplot[[Sequence @@ Append[[email protected][[#]], 1]]]) &,
[email protected]]);
(* Substitute all the lines with line buttons *)
Array[(plot[[Sequence @@ [email protected][[#]]]] = Button[line[#],
AddLabel[lbl[[#]]]]) &, [email protected]];
Dynamic[EventHandler[plot,
"MouseDown" :> (pt = MousePosition["Graphics"])]]
Dưới đây là giao diện. Sau khi chú thích, đối tượng đồ họa đơn giản có thể được tìm thấy được đặt thành biến 'plainplot'.
Vấn đề hưởng lẫn nhau giữa 'Mesh' và' PlotMarkers' đã đưa ra trong [SO câu hỏi này] (http://stackoverflow.com/questions/4789047/custom-intervals-of-markers- trong toán học-plotmarkers/4790805 # 4790805). Tôi đã báo cáo nó cho WRI vào thời điểm đó và hỗ trợ kỹ thuật đã chuyển nó lên nhóm phát triển để xem xét. Hy vọng rằng nó sẽ được sửa trong bản phát hành tiếp theo. – Simon
Tôi tò mò tại sao một số tùy chọn Mesh hoạt động trong khi nhiều tùy chọn khác không hoạt động. –
Đối với câu hỏi thứ ba của bạn, bạn có thể muốn xem biểu đồ tôi đã sử dụng tại đây: http://stackoverflow.com/questions/5745298/how-do-i-access-the-stackoverflow-api-from-mathematica/5745783 # 5745783. Điều này bao gồm chú thích thủ công (có thể được thực hiện để hoạt động bán tự động). Tôi cảm thấy kết quả cuối cùng là dễ chịu hơn nhiều so với nhiều phương pháp khác. –