I'd need to write an interactive plot. I have some function I defined and some point lists I get from external data file. I'd need to see those data along with my functions, and I know how to do that. However I would also like to have a checklist, and by clicking over each button I should be able to show/hide a function or a data point set.

I don't need the full code, just a hint about how to get a checklist, and how to make it dynamically affect the function I'm plotting would be great!

{set6, set9} = RandomReal[{-1, 1}, {#, 2}] & /@ {6, 9};
{p6, p9} = Interpolation[#, Method -> "Spline"] & /@ {set6, set9};
With[{in = Indeterminate}, 
    Plot[{If[t6p, p6@x, in], If[t9p, p9@x, in], in}, {x, -1, 1}, PlotRange -> {{-1, 1}, 5 {-1, 1}}], 
    ListPlot[{If[t6s, set6, in], If[t9s, set9, in], in}, PlotStyle -> PointSize[Large]]],
  Grid[{{Control[{t6s, {True, False}}], Spacer[10], Control[{t6p, {True, False}}]}, 
        {Control[{t9s, {True, False}}], Spacer[10], Control[{t9p, {True, False}}]}}]]]

Mathematica graphics

  • $\begingroup$ "just a hint" :) $\endgroup$ – cormullion Dec 27 '13 at 17:23
  • 1
    $\begingroup$ @cormullion It may seem simple for an experienced user, but there are a lot of possible pitfalls in that code for a novice. I preferred to post a small working example than to elaborate on the caveats. Do you think it's out of place? $\endgroup$ – Dr. belisarius Dec 27 '13 at 17:27
  • 1
    $\begingroup$ No not at all! :) The great thing about this site is how you experts give so much more than the minimum necessary... $\endgroup$ – cormullion Dec 27 '13 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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