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

Manipulate

Manipulate
generates a version of expr with controls added to allow interactive manipulation of the value of u.
Manipulate
allows the value of u to vary between and in steps du.
Manipulate
takes the initial value of u to be .
Manipulate
labels the controls for u with .
Manipulate
allows u to take on discrete values .
Manipulate
provides controls to manipulate each of the .
Manipulate
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,{u1->lbl1,u2->lbl2,...}}setter bar or popup menu with labels for elements
{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
{{u,uinit,ulbl},...}control with label
{{u,...},...,opts}control with particular options
Control[...]general control object
Delimiterhorizontal delimiter
string, view, cell expression, etc.explicit text, view, cell, etc. annotations
  • Inside annotations, controls can be specified using Control.
  • The label 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 specifies that a particular variable should be controlled by a trigger.
  • The control specification {u, umin, umax, ..., Appearance->"Labeled"} yields a slider with the value displayed as a label.
  • In the form , Dynamic[u] is given as the first argument to func.
  • The form can also be used; what is evaluated is then func[Dynamic[u], {umin, umax}].
  • 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 , and makes the value of u be the list of all .
  • The form {{u, uinit}, {xmin, ymin}, {xmax, ymax}, Locator} specifies a range for the locators.
  • The option setting LocatorAutoCreate 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 placement of an annotation can be specified by enclosing it in an Item that has a ControlPlacement option.
  • 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
Bookmarks{}bookmark settings
ContentSizeAutomaticthe absolute size for the content area
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
InterpolationOrderAutomaticinterpolation order for animating transitions between bookmarks
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
UnsavedVariablesNonevariables whose values should not be saved
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
  • Manipulate is a scoping construct that implements lexical scoping.
  • With the default setting UnsavedVariables, 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 setting for AppearanceElements can be a list in any order of the following: , , , . By default, only is included.
  • Clicking the snapshot button creates a cell directly below the Manipulate output, containing input of the form With specifying current values of all variables.
  • With the setting ContinuousAction->None, an explicit Update button is displayed, and expr is not reevaluated until this is clicked.
  • 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:
or xprimary x value
or yprimary y value
or zprimary z value
or {x,y}primary 2-axis controller value
or {x,y,z}primary 3-axis controller value
, , , etc.x, y, , etc.values from a secondary controller
, etc.x, etc.values taken to be cyclic
, etc.x, etc.values from absolute control positions
, , etc., , etc.toggling button states
, , etc., , 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 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 , the absolute position of a control such as a joystick determines the value of the corresponding variable x.
  • With a controller specification such as , 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 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, typically refers to the left joystick, and to the right one. If a gamepad has a "hat" control, this is typically referred to as .
  • Button controller specifications such as toggle between True and False whenever the corresponding button is pressed.
  • Absolute specifications such as 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 and styles in the current stylesheet.
Manipulate a continuous parameter:
Manipulate a parameter in discrete steps:
Manipulate two parameters:
Give defaults and names for parameters:
Manipulate a continuous parameter:
 
Manipulate a parameter in discrete steps:
 
Manipulate two parameters:
 
Give defaults and names for parameters:
Manipulate any type of content including numbers:
Formulas:
Programs:
2D graphics:
3D graphics:
Controls:
Use a number of standard controls including Checkbox:
SetterBar with labels for each element:
Multiple Locator objects:
Allow additional locators to be created with Alt+Click:
Use any number of controls:
Use Control inside constructs like Row or Grid to lay out your controls in arbitrary ways:
Use ControlType to specify the type of control:
Use a pure function to write a custom control type:
Link a single variable to multiple controls:
Use default values and annotations for individual controls:
Use any type of expression as an annotation, including typesetting and graphics:
Make the annotation update dynamically:
Break Manipulate controls into groups using Delimiter, Item, etc.:
Use ControlPlacement to place individual controls:
Use both ControlPlacement and annotation elements:
Use dynamically updating annotations as well:
Annotations can contain Control objects or other layout constructs:
By default, controllers only affect a Manipulate when it is selected; use All to override this:
Use ControllerPath to specify the class of controller to use:
Setting ControllerMethod to forces absolute associations rather than relative ones:
You can interactively rotate 3D graphics while changing parameters:
Set up a variable number of locators:
Use preset values:
By default Manipulate only contains a Manipulator:
Use AppearanceElements to specify more controls to be displayed:
By default no values change until you click in the slider area:
By setting AutoAction, the values change as the mouse moves over the slider area:
By choosing Autorun from the Manipulate menu, each variable is automatically run through:
Use AutorunSequencing to control the order of variables in Autorun:
Specify a different duration for each variable (default 5):
Specify All to run through all variables simultaneously:
Align with the surrounding text:
By default, variables are continuously updated:
Setting ContinuousAction to False updates only when the control is released:
Setting it to None does not update the contents until the Update button is clicked:
By default, the output will respond to an external controller if the object is selected:
Using Full makes the output respond only if the object is within the current selection:
Using All makes the output always respond to external controllers:
Using True makes the output respond whenever the notebook has focus:
Using False makes the output never respond to external controllers:
By default, the variables will be associated with suitable controls on the controller device:
Setting ControllerMethod to forces absolute associations rather than relative ones:
By default, Manipulate responds to the first controller that supports all necessary controls:
Use to specify a controller typically including two analog controls:
Use to specify a controller typically including one primary analog control:
Use for controllers such as those with six analog degrees of freedom:
Use to specify a controller not built into a computer:
Use to specify a controller built into a computer:
Specify the location of the controls:
ControlPlacement also affects annotations, whether or not they contain Control objects:
By default Manipulate chooses a Manipulator to control the specified variable:
Use ControlType to specify the type of control to use, including None:
Specify the control type for each Manipulate variable separately:
ControlType can be combined with individual variable control specifications:
ControlType affects controls specified by Control in the same way:
In the Automatic setting, an appropriate controller is selected:
Use Deinitialization to evaluate expressions when Manipulate is no longer displayed:
By default both the content and the controls are interactive:
Use Deployed to restrict interactivity to the controls:
Specify a label at the bottom:
Specify different labels at the bottom and on the left:
Specify labels on each side:
Use preset values for the margins around the content area:
Or use explicit values:
Use symbolic values:
Or use explicit values:
Use Initialization to specify evaluations necessary for the Manipulate output:
Specify stylistic details for labels:
Use compound styles:
Frame labels are affected by LabelStyle:
By default the variables are localized:
By setting LocalizeVariables, the variables are treated as global:
Specify whether the output should be wrapped in a panel:
Specify whether frame labels should be rotated in the vertical position:
By default, external definitions are lost between kernel sessions:
By setting SaveDefinitions to True the external definitions are saved with the output:
By default, the initializations are done synchronously:
Force asynchronous initialization:
By default the evaluation will time out after five seconds:
SynchronousUpdating is disabled; the evaluation will not time out:
Specify symbols that will be used for updating:
Define an operations table:
Manipulate the operations tables for :
A general linear transformation of a graphics object:
Solve a boundary value problem by interactively manipulating the initial values:
Use InputForm to get Manipulate input:
InputForm on the actual object also reflects the current state:
Use Setting on the output to access the displayed expression:
Use Dynamic to localize updates and prevent the entire expression from updating:
Use Appearance to display all the Manipulator controls:
When manipulating plots, the PlotRange may vary and cause resizing:
Use a fixed PlotRange to prevent resizing:
When manipulating plots, the tick sizes may vary and cause resizing:
Use either a fixed PlotRange or ImagePadding to prevent resizing:
Manipulate only "notices" explicit visible parameters:
The parameter is not explicitly visible in :
Redefine to include the parameter explicitly:
Manipulate the electrostatic potential built from point charges:
Create a simple polyhedron property explorer:
Visualize solutions to a linear system of differential equations :
Create a variable number of controls:
New in 6 | Last modified in 7