Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
{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

share|improve this answer
"just a hint" :) – cormullion Dec 27 '13 at 17:23
@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? – Dr. belisarius Dec 27 '13 at 17:27
No not at all! :) The great thing about this site is how you experts give so much more than the minimum necessary... – cormullion Dec 27 '13 at 18:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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