Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Combining Slider and SetterBar in Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115367] Re: Combining Slider and SetterBar in Manipulate
  • From: Jeff Bryant <jeffb at wolfram.com>
  • Date: Sun, 9 Jan 2011 02:18:07 -0500 (EST)

Sorry for not replying sooner, but I think this can be drastically simplified using the code below unless I have missed something from your original query:

Manipulate[
 ListLinePlot[someData[[tinx, 2 ;;]]],
 {{tinx, 1, "Time"}, 1, 25, 1, 
  Appearance -> "Labeled"}, 
{{tinx, 1, "Special"}, {7 -> "Rising", 
   5 -> "Smile", 20 -> "Saws", 12 -> "Falling"}, 
  ControlType -> SetterBar},
 {{someData, Table[Sin[i j]*Cos[j] // N, {i, 25}, {j, 12}]}, 
  ControlType -> None}]

Some things to note:

1) As pointed out by John Fultz, Block is not a good idea. In fact, localizing someData can be achieved by just using ControlType->None and setting the initial value of someData to the Table

2) Appearance -> "Labeled" will tell you the current value in a much cleaner way than using the Pane

3) Having two controls, each tied to the same a parameter is completely supported. In this case, the first instance is a Manipulator and the second instance is a SetterBar. Changing either control updates the value of tinx locally in this Manipulate

As a side note, I'll mention that its good to always use AutorunSequencing when you use ControlType-> None variables. Autorun is a "menu" item under the + menu in the upper right of the Manipulate output that tries to run each control through its full range. ControlType -> None controls may not have defined bounds so it may not make sense to Autorun them and so 

AutorunSequencing -> {1} 

says to only run the first control and ignore any others. If you never use Autorun or export this Manipulate to Flash, you can skip this. We're going for simplicity here so I didn't add this option to the code above.


  • Prev by Date: Re: Solving very large systems of ODEs with NDSolve
  • Next by Date: Re: Tensor cross vector
  • Previous by thread: Re: Combining Slider and SetterBar in Manipulate
  • Next by thread: AstronomicalData. How can be taken into account when a planet is