Wolfram Language Fast Introduction for Programmers
Get Started »

Options

Wolfram Language functions allow an arbitrary number and type of options to be included as arguments in any order. Recreating this functionality in Java requires method overloading, optional classes or other additional programming logic.

Options in the Wolfram Language are similar to optional arguments for Python functions, except options in the Wolfram Language use the arrow symbol, while Python uses the equals sign =.

Many built-in functions have options that affect details of their operation or output:

In[1]:=
X
Out[1]=

Options gives the default options of a function:

In[2]:=
X
Out[2]=

Automatic is a common default setting, meaning make an automatic choice.

Some options are often given as pure functions. Parentheses are needed when you use &

In[3]:=
X
Out[3]=

Use option:>value to make value be reevaluated every time the option is used.

Check Your Understanding

Which of the following plots has no options?

Plot[Sin[x], {x, 0, 10}, ImageSize Small]

Incorrect. This includes an option for the image size.

Plot[Sin[x], {x, 0, 10}, ImageSize Small, PlotLabel "Sine Wave"]

Incorrect. This includes an option for the image size as well as a plot label.

Plot[Sin[x], {x, 0, 10}]

Correct.

Plot[Sin[x], {x, 0, 10}, Axes False, ColorFunction Hue]

Incorrect. This includes an option for the axes as well as a color function.

Which of the following has an option that specifies a green background?

Plot[Sin[x], {x, 0, 10}, Background Green]

Correct.

Plot[Sin[x], {x, 0, 10}, Background = Green]

Incorrect. Options are given as rules.

Plot[Sin[x], {x, 0, 10}]

Incorrect. This has no options.

Which of the following graph plots has an option that correctly specifies a disk for rendering vertices?

GraphPlot[{1 2, 2 3, 3 1}, VertexRenderingFunction (Disk[#] &)]

Correct.

GraphPlot[{1 2, 2 3, 3 1}, VertexRenderingFunction Disk[#] &]

Incorrect. When pure functions are given as options, they need to be put in parentheses.

GraphPlot[{1 2, 2 3, 3 1}]

Incorrect. This has no options.