# Manipulate Properties to Add Scroll Bars in Dynamic Object?

I am interested in trying to produce a dynamic object of a plot of 20 functions, where users are able to select one of 20 functions in given plot. Here is my oversimplified non-working code:

Manipulate[
Plot[function[x], {x, 0, 2 Pi}], {function, {g1, g2, g3, g4, g5, g6,
g7, g8, g9, g10, g11, g12, g13, g14, g15, g16, g17, g18, g19, g20},
ControlType -> CheckboxBar, BaselinePosition -> Center,
Method -> "Active", Appearance -> "Horizontal"}]


When one executes this piece of code, it is clear to note that the check boxes extend past the plot and the size of the dynamic object. Is there a Manipulate option that would enable me to list out the 20 functions so that one can scroll through the check boxes horizontally (with a scroll bar) and select the appropriate function they would like to see on the plot?

Thank you for your time!

Is this what you need?

Manipulate[Plot[function[x], {x, 0, 2 Pi}],
Pane[Control@{function, {g1, g2, g3, g4, g5, g6, g7, g8, g9, g10,
g11, g12, g13, g14, g15, g16, g17, g18, g19, g20},
ControlType -> CheckboxBar, BaselinePosition -> Center,
Method -> "Active", Appearance -> "Horizontal"},
Full, Scrollbars -> {True, False}, AppearanceElements -> None]
]


You can change Full size spec of Pane to whatever fixed value you want.

• Thank you! This is what I need! One more question. How can you control the position of Pane? Thanks! – Wilson Nov 26 '16 at 9:48
• @Wilson You can use ControlPlacement option. You can always use DynamicModule and assemble elements however you like. – Kuba Nov 26 '16 at 9:52

Perhaps the following will provide a starting point. I'd suggest that you first remove the extra formatting from the CheckboxBar, in particular the Appearance -> "Horizontal" part: this will allow Mathematic to format the list of functions over multiple rows and require no scrolling to reach all of them.

Manipulate[
Plot[Evaluate@Through[function[x]], {x, -2 Pi, 2 Pi}],
{{function, {Sin}}, {Sin, Cos, Sinc, Tan}, ControlType -> CheckboxBar}
]


In the code above, Through allows you to apply the same argument to a list of functions contained in function; Evaluate is added so Plot will explicitly be aware of the fact that its argument is a list, and style the different plots accordingly.

As a starting point, I'd also suggest that you take a look at the values of function itself as they change with user selection, before working on the plotting.

If you want only one function plotted at a time, then RadioButtonBar would perhaps be a more appropriate control choice, as it allows for mutually exclusive selections, i.e. for only one function being selected at any time.

• Thank you for your input. I am aware that my code isn't working and I don't need a fix for it since I have a bigger program that I am currently working on. This program has the same issues that I have in the example above. If we take your code and list 20 functions instead of 4 functions, you will see that the list extends the dynamic object. Is there a way to avoid this? Thanks! – Wilson Nov 26 '16 at 8:27