This question was inspired by this answer.

Consider we have set of data:

data = RandomReal[1, {10, 5}]

Command which allows to plot arbitrary the columns is

 ListLogPlot[TableOutputTotal[[All, {j, k}]], 
  Joined -> True], {{j, 1}, Range[10], SetterBar}, {{k, 2}, Range[10],

Is there any way to introduce interactive plot legends? Say, if I plot columns 1 and 2, there will be a legend "Quantity 1", "Quantity 2", for 3 and 5 there will be "Quantity 3", "Quantity 5" and so on.

  • $\begingroup$ What have you tried? if you understand the other answer you could guess some and search for the rest. You must show your due diligence. $\endgroup$
    – rhermans
    Commented Jul 27, 2018 at 14:45

1 Answer 1


To have reproducible results you need to use SeedRandom prior to generating the random numbers.

data = RandomReal[1, {10, 5}];

There are only five columns so the controls should only go to five. To use PlotLegends you must plot each column separately. This requires you to Transpose the extracted data.

 ListLogPlot[Transpose@data[[All, {j, k}]],
  Joined -> True,
  PlotLegends -> (Style[StringForm["Quantity ``", #], 14, Bold] & /@ {j, k})],
   Control[{{j, 1, Style["j", 14, Bold]}, Range[5], SetterBar}],
   Control[{{k, 2, Style["k", 14, Bold]}, Range[5], SetterBar}]}]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.