1
$\begingroup$

I'd like to create a tabview with conditions on it, rather than put the tabview inside an If statement, to reduce the length of my code. i.e.

switcher=False
TabView[{
  "a" -> Plot[x^2, {x, 0, 10}],
  Evaluate@If[switcher, "b" -> Plot[x^3, {x, 0, 10}]],
  "c" -> Plot[x^4, {x, 0, 10}]
  
  }]

Trouble is that when I run this It creates a Tab where the Plot is still visible for x^3, any suggestions on how to fix?

$\endgroup$

1 Answer 1

1
$\begingroup$

nevermind, finally realized using

switcher=False
TabView[{
  "a" -> Plot[x^2, {x, 0, 10}],
  If[switcher, "b" -> Plot[x^3, {x, 0, 10}],Nothing],
  "c" -> Plot[x^4, {x, 0, 10}]
  
  }]

does the trick

$\endgroup$

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.