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

OptionsPattern

OptionsPattern
is a pattern object that represents a collection of options given as rules, where the values of the options can be accessed using OptionValue.
OptionsPattern[f]
takes default option values from Options[f].
OptionsPattern
uses an explicit list of default option values.
  • OptionsPattern matches any sequence or nested list of rules, specified with or .
  • In OptionsPattern the can be either heads or explicit rules . Each head is treated as the list of rules obtained from Options.
  • OptionsPattern uses the default options of the nearest enclosing function.
Define default option values for the function :
Define , allowing options to be given:
Use with an explicit option setting:
Use with options taken to have their default values:
Define default option values for this assignment without explicitly setting up Options:
Take default option values from Plot:
Use the defaults from Plot:
Override one of the defaults from Plot:
Define default option values for the function :
In[1]:=
Click for copyable input
Define , allowing options to be given:
In[2]:=
Click for copyable input
Use with an explicit option setting:
In[3]:=
Click for copyable input
Out[3]=
Use with options taken to have their default values:
In[4]:=
Click for copyable input
Out[4]=
 
Define default option values for this assignment without explicitly setting up Options:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
 
Take default option values from Plot:
In[1]:=
Click for copyable input
Use the defaults from Plot:
In[2]:=
Click for copyable input
Out[2]=
Override one of the defaults from Plot:
In[3]:=
Click for copyable input
Out[3]=
New in 6