Explore the latest version of An Elementary Introduction to the Wolfram Language »
9Interactive Manipulation
The slider lets you pick values of n between 1 and 5 (in steps of 1):
In[1]:=
Click for copyable input
Out[1]=
Heres the whole sequence of possible results:
In[2]:=
Click for copyable input
Out[2]=
Heres a similar interface for displaying a column of powers of a number:
In[3]:=
Click for copyable input
Out[3]=
And heres the list of possible results in this case:
In[4]:=
Click for copyable input
Out[4]=
Unlike Table, Manipulate isnt limited to a fixed set of possible values. If you simply omit the step size in Manipulate, itll assume you want any possible value in the range, not limited to whole numbers.
In[5]:=
Click for copyable input
Out[5]=
A bar chart that changes as you move the slider:
In[6]:=
Click for copyable input
Out[6]=
A pie chart of the same list:
In[7]:=
Click for copyable input
Out[7]=
Manipulate lets you set up any number of controls. You just give the information for each variable in turn, one after another.
Build an interface to vary the number of sides, and the hue, of a polygon:
In[8]:=
Click for copyable input
Out[8]=
There are many ways to specify controls for Manipulate. If you give a list of possible values, youll get a chooser or menu.
Build an interface that lets you choose between three colors:
In[9]:=
Click for copyable input
Out[9]=
If there are more choices, like for size here, Manipulate sets up a drop-down menu:
In[10]:=
Click for copyable input
Out[10]=
Manipulate[anything,{n,0,10,1}] manipulate anything with n varying in steps of 1
Manipulate[anything,{x,0,10}] manipulate anything with x varying continuously
9.1Make a Manipulate to show Range[n] with n varying from 0 to 100. »
Expected output:
Out[]=
9.2Make a Manipulate to plot the whole numbers up to n, where n can range from 5 to 50. »
Expected output:
Out[]=
9.3Make a Manipulate to show a column of between 1 and 10 copies of x»
Expected output:
Out[]=
9.4Make a Manipulate to show a disk with a hue varying from 0 to 1. »
Expected output:
Out[]=
9.5Make a Manipulate to show a disk with red, green and blue color components varying from 0 to 1. »
Expected output:
Out[]=
9.6Make a Manipulate to show digit sequences of 4-digit integers (between 1000 and 9999). »
Expected output:
Out[]=
9.7Make a Manipulate to create a list of between 5 and 50 equally spaced hues. »
Expected output:
Out[]=
9.8Make a Manipulate that shows a list of a variable number of hexagons (between 1 and 10), and with variable hues. »
Expected output:
Out[]=
9.9Make a Manipulate that lets you show a regular polygon with between 5 and 20 sides, in red, yellow or blue. »
Expected output:
Out[]=
9.10Make a Manipulate that shows a pie chart with a number of equal segments varying from 1 to 10. »
Expected output:
Out[]=
9.11Make a Manipulate that gives a bar chart of the 3 digits in integers from 100 to 999. »
Expected output:
Out[]=
9.12Make a Manipulate that shows n random colors, where n can range from 1 to 50. »
Sample expected output:
Out[]=
9.13Make a Manipulate to display a column of integer powers with bases from 1 to 25 and exponents from 1 to 10. »
Expected output:
Out[]=
9.14Make a Manipulate of a number line of values of x^n for integer x from 1 to 10, with n varying from 0 to 5. »
Expected output:
Out[]=
9.15Make a Manipulate to show a sphere that can vary in color from green to red. »
Expected output:
Out[]=
+9.1Make a Manipulate to plot numbers from 1 to 100 raised to powers that can vary between 1 and +1. »
Expected output:
Out[]=
+9.2Make a Manipulate to display 1000 at sizes between 5 and 100. »
Expected output:
Out[]=
+9.3Make a Manipulate to show a bar chart with 4 bars, each with a height that can be between 0 and 10. »
Expected output:
Out[]=
Does Manipulate work the same on web, mobile and desktop?
Ultimately yes. But it can be significantly slower on the web and on some mobile systems, because every time you move a slider it has to communicate over the internet with a server to find out what to do. On desktop and some mobile systems, everything is happening right there, inside your computer or other deviceso its very fast.
Can I make a standalone app out of a Manipulate?
Yes. To make a web app, for example, you just need to use CloudDeploy. Well talk about this in Section 36.
Can I use random numbers in Manipulate?
Yes, but unless you seed them with SeedRandom, the random numbers will be different every time you move a slider.
The Wolfram Demonstrations Project: more than 11,000 interactive Demonstrations created with Manipulate
 
Download Notebook Version
es