Skip to main content

Manipulate

Wolfram Kernel
Execution environment
Manipulate[expr_, {u_Symbol, min_, max_}..]
Manipulate[expr_, {{u_Symbol, initial_}, min_, max_}..]
Manipulate[expr_, {{u_Symbol, initial_}, min_, max_, step_}..]
Manipulate[expr_, {{u_Symbol, initial_, label_String}, min_, max_, step_}..]

generates a version of expr with controls added to allow interactive reevaluation

Manipulate[expr_, {{u_Symbol}, values_List}..]
Manipulate[expr_, {{u_Symbol, initial_}, values_List}..]
Manipulate[expr_, {{u_Symbol, initial_, label_String}, values_List}..]

Options

"UpdateFunction"

Allows to alter the expression, prevent default actions or cause side-effects upon update. The following return values are expected

Function[input,
(* side effects *)
(* RETURN *)
True <- accept change
False <- prevent default
_String <- will be written instead
]

One can completely bypass the default reevaluation and use side-effects only

Module[{r},
Manipulate[Graphics[Disk[{0,0}, r//Offload]],
{{radius, 1}, 0,1},
"UpdateFunction" -> Function[value,
r = value;
False (* always reject *)
]
]
]

However, we do recommend to use InputRange directly instead of Manipulate for such cases.

ContinuousAction

By the default is False, which means that any update happens after users action, but not before.

"ControlsLayout"

By the default is "Vertical", another possible value is "Horisontal"

Examples

Manipulate Series

Manipulate[Series[Sinc[x], {x, 0, n}], {n, 1, 5, 1}]

Manipulate[Plot3D[Sin[n x] Cos[n y], {x,-1,1}, {y,-1,1}], {n, 1, 5, 1}]

warning

Manipulate reevaluates the whole expression similar to Refresh, which is a huge overhead for the system. Please, consider to use ManipulatePlot, AnimatePlot, ManipulateParametricPlot or general dynamics using Offload (see Dynamics) for any plots, rapidly changing data and smooth transitions instead of Manipulate.

Manipulate is caching all results by the default.

Example with mixed symbolics and graphics

MMAView

MMAView wrapper allows to use native Wolfram Engine rendering engine for manipulate expressions, any expression. It uses a parallel kernel to rasterize the provided expression and stream updates to the frontend.

Manipulate[Plot3D[Sin[n x] Cos[n y], {x,-1,1}, {y,-1,1}], {n, 1, 5, 1}] // MMAView

Try to drag and rotate the plot We automatically detect if the manipulate expression is [[Graphics3D]] and if so, we provide additional mouse controls.

warning

It literally streams uncompressed raster images in real-time. Please do not overuse it, and try to use WLJS dynamics in general if possible.

Supported output forms