This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Manipulate

Manipulate[expr, {u, umin, umax}]
generates a version of expr with controls added to allow interactive manipulation of the value of u.
Manipulate[expr, {u, umin, umax, du}]
allows the value of u to vary between umin and umax in steps du.
Manipulate[expr, {{u, uinit}, umin, umax, ...}]
takes the initial value of u to be uinit.
Manipulate[expr, {{u, uinit, ulbl}, ...}]
labels the controls for u with ulbl.
Manipulate[expr, {u, {u1, u2, ...}}]
allows u to take on discrete values u1, u2, ....
Manipulate[expr, {u, ...}, {v, ...}, ...]
provides controls to manipulate each of the u, v, ....
Manipulate[expr, "cu"->{u, ...}, "cv"->{v, ...}, ...]
links the controls to the specified controllers on an external device.
  • The expression expr can be any graphic or other expression. If it is None, only the controls are displayed.
  • The following forms by default yield particular forms of controls:
{u,umin,umax}manipulator (slider, animator, etc.)
{u,umin,umax,du}discrete manipulator with step du
{u,{xmin,ymin},{xmax,ymax}}2D slider
{u,Locator}a locator in a graphic
{u,{u1,u2,...}}setter bar for few elements; popup menu for more
{u,{True,False}}checkbox
{u,color}color slider
{u}blank input field
{u,func}create an arbitrary control from a function
{{u,uinit},...}control with initial value uinit
{{u,uinit,ulbl},...}control with label ulbl
{{u,...},...,opts}control with particular options
Delimiterhorizontal delimiter
string, cell expression, etc.explicit text, cell, etc. annotations
  • The label ulbl for a control can be any expression.
  • The option setting ControlType->type attempts to use controls of the specified type.
  • ControlType options can be given separately for each variable. Options for the controls can also be given within the specification for the variables.
  • ControlType->Trigger specifies that a particular variable should be controlled by a trigger.
  • The control specification {u, umin, umax, ..., Appearance->"Labeled"} yields a slider with value displayed as a label.
  • In the form {u, func}, Dynamic[u] is given as the first argument to func.
  • The form {u} is equivalent to {u, InputField}. {u, ColorSlider} gives a default color slider as a control.
  • In the form {u, Locator}, the value of u is a list giving x and y coordinates. The coordinates refer either to the first graphic in expr, or range from 0 to 1 in each direction across expr.
  • The form {{u, {{x1, y1}, {x2, y2}, ...}}, Locator} sets up a locator for each of the {xi, yi}, and makes the value of u be the list of all {xi, yi}.
  • The option setting LocatorAutoCreate->All specifies that new locators should be added for clicks that do not hit existing locators. Alt+Click deletes locators.
  • If a variable u is used more than once, linked controls for it are given.
  • The option setting ControlPlacement->pos specifies that controls should be placed at position pos relative to expr. Possible settings for pos are Bottom, Left, Right and Top.
  • The following overall options can be given:
AlignmentAutomatichow to align the output in the display area
AppearanceElementsAutomaticoverall control elements to include in the displayed output
AutoActionFalsewhether to change controls automatically when the mouse is over them
AutorunSequencingAutomatichow autorun should use the controls
BaselinePositionAutomaticalignment relative to surrounding text
BaseStyle{}base style specifications for the Manipulate
ContinuousActionAutomaticwhether to update continuously when controls are changed
ControllerLinkingAutomaticwhen to activate links to external controllers
ControllerMethodAutomatichow external controllers should operate
ControllerPathAutomaticwhat external controllers to try to use
ControlPlacementAutomaticplacement of controls
ControlTypeAutomatictype of controls to use
DeinitializationNonean expression to be evaluated if the output from the Manipulate is deleted
DeployedFalsewhether to make the displayed output deployed
EvaluatorAutomaticthe kernel to use for evaluations
FrameLabelNonelabels for the outer frame
FrameMarginsAutomaticmargins inside the overall frame
ImageMargins0margins around the whole Manipulate
InitializationNonean expression to be evaluated when output is first displayed
LabelStyle{}style specifications for the controls area
LocalizeVariablesTruewhether to localize the variables
PaneledTruewhether to put the displayed output in a panel
PreserveImageOptionsTruewhether to preserve image size and other options when regenerating graphics
RotateLabelFalsewhether to rotate y labels on the frame
SaveDefinitionsFalsewhether to save all definitions associated with expr
ShrinkingDelay0how long to delay before shrinking if the displayed object gets smaller
SynchronousInitializationTruewhether to perform initialization synchronously
SynchronousUpdatingAutomaticwhether to update synchronously
TrackedSymbolsFullsymbols whose changes trigger updates in the output
  • The options ControlPlacement, ControlType, PreserveSettings and ResetButton can be given separately for each variable, in the form {u, spec, opts}.
  • With the default setting PreserveSettings->True, values of the variables u, v, etc. are automatically saved in notebooks, and restored when the notebooks are reopened.
  • With a setting Initialization:>expr, the expression expr is evaluated when Manipulate is executed, or when the result is first displayed in a particular session.
  • The following elements are included in default output from Manipulate: "HideControlsButton", "SnapshotButton" and "BookmarksButton". "ResetButton" is also supported. The elements can be specified in any order in a list given as the setting for AppearanceElements.
  • Pressing the snapshot button creates a cell directly below the Manipulate output, containing input of the form With[{u=uval, ...}, expr] specifying current values of all variables.
  • With the setting ContinuousAction->None, an explicit Update button is displayed, and expr is not re-evaluated until this is pressed.
  • With TrackedSymbols->All, the output is updated whenever any symbol encountered in its evaluation is changed.
  • Controllers on an external device such as a gamepad can include joysticks, buttons, etc.
  • Typical external controller specifications include:
"X" or "X1"xprimary x value
"Y" or "Y1"yprimary y value
"Z" or "Z1"zprimary z value
"XY" or "XY1"{x,y}primary 2-axis controller value
"XYZ" or "XYZ1"{x,y,z}primary 3-axis controller value
"X2", "Y2", "XY2", etc.x, y, {x, y}, etc.values from a secondary controller
"XCyclic", etc.x, etc.values taken to be cyclic
"XAbsolute", etc.x, etc.values from absolute control positions
"B1", "B2", etc.b1, b2, etc.toggling button states
"B1Absolute", "B2Absolute", etc.b1, b2, etc.instantaneous button states
  • Raw external controller specification names for devices active in a particular Mathematica session can typically be found using ControllerInformation.
  • With the default setting ControllerMethod->Automatic, a controller specification such as "X" means that the displacement of a control such as a joystick by default determines the rate of change of the corresponding variable x. If an alternate state is selected, for example by depressing the joystick, then the absolute position of the control directly determines the value of x.
  • With a controller specification such as "XAbsolute", the absolute position of a control such as a joystick determines the value of the corresponding variable x.
  • With a controller specification such as "XCyclic", the value of the corresponding variable x is typically taken to wrap around cyclically when the control reaches the end of its range.
  • A controller specification such as "XYZ" may be associated with multiple controls on an external device, such as axes on two distinct joysticks on a single controller.
  • On a gamepad or other device with two joysticks, "XY1" typically refers to the left joystick, and "XY2" to the right one. If a gamepad has a "hat" control, this is typically referred to as "XY3".
  • Button controller specifications such as "B1" toggle between True and False whenever the corresponding button is pressed.
  • Absolute specifications such as "B1Absolute" yield True while the button is being pressed, and False otherwise.
  • The settings for BaseStyle and LabelStyle are appended to the default styles typically given by the "Manipulate" and "ManipulateLabel" styles in the current stylesheet.
New in 6