Questions tagged [options]

Questions dealing with optional named arguments of Mathematica functions.

Questions dealing with optional named arguments of Mathematica functions. Questions related to how to write functions with options (OptionsPattern), how to query options (Options and AbsoluteOptions) and option values (OptionValue), how to filter options (FilterRules), pass on options to internal functions (Rule and RuleDelayed), extract option values (Replace), set options globally (SetOptions) and how to change option values belong to here.

Questions about in what order/syntax should optional arguments be listed when calling (built-in) functions should use the tag .

Useful links:

620 questions
25
votes
5 answers

How can I work out which functions work with SetOptions?

Not all functions seem to work with SetOptions. e.g. SetOptions[Grid, BaseStyle -> Directive[Red]]; Grid[{{"hello", "world"}}] hello world the font is not red. SetOptions[Row, BaseStyle -> Directive[Red]]; Row[{"hello", "world"}] hello…
Mike Honeychurch
  • 37,541
  • 3
  • 85
  • 158
19
votes
2 answers

How do I get a list of allowed values for an option?

When using Mathematica how can I get a list of the allowed values of an option? As an example I can use the Options command as follows - Options[Manipulate] which gives me a list of available options (*…
David McHarg
  • 1,643
  • 1
  • 15
  • 28
15
votes
1 answer

Problem using OptionValue with functions defined by SubValues, and the use of Options for function dispatch

I have a function that looks like: (a : pump[_, __])["curve QH", opts : OptionsPattern[]] := Plot[x, {x, 0, 2}, Frame -> True, FrameLabel -> {"a", "b"}, Evaluate[FilterRules[{opts}, Options[Plot]]] This code allows me to substitute the option…
P. Fonseca
  • 6,665
  • 2
  • 28
  • 60
13
votes
1 answer

What is Hessian?

I was working today and had to calculate the Hessian of a matrix, then I wondered a Hessian function might already exist. I typed Hessian and it does exist, but there's no documentation (neither online nor software embedded) that explains what the…
QuantumBrick
  • 499
  • 2
  • 9
11
votes
2 answers

Setting options of expressions similar to using SetOptions on objects

Introduction I often have the problem that in an expression, I want to change an option. If we are sure the option is not present, we could simply use Append[expression, opt -> val]. But sometimes such an expression is very long and it can be a bit…
Jacob Akkerboom
  • 12,215
  • 45
  • 79
10
votes
0 answers

How can I obtain the absolute settings of some Grid options?

For example: Grid[{{10!}, {5!}}, ItemSize -> Full, Frame -> All] What's the real value of Full? How can I map the Full to a 2-d array? {{1, 2, 3, 4, 5 ... }, {1, 2, 3, 4, 5 ... }} Similarly there are some other values like {Scaled[.3]}, Automatic,…
HyperGroups
  • 8,619
  • 1
  • 26
  • 63
9
votes
1 answer

Options of symbols without evaluating them

Try the following on a fresh kernel in 11.3 Options[Unevaluated[Plot]] (* {} *) The problem is that Plot -besides many other functions- is now auto-loaded when you need it. When you call Options[Plot] it shows all options, because in the…
halirutan
  • 112,764
  • 7
  • 263
  • 474
7
votes
1 answer

Way to add a same option to multiple functions

Just wanna figure out if there is a decent way to add a same option to multiple functions simultaneously. For example I have a series of SoundNote: Sound[{SoundNote["D4", {0.4, 0.2}], SoundNote["G4", {0.6, 0.2}], SoundNote["B4", {0.8, 0.2}],…
7
votes
3 answers

How to return the value of Automatic when it is used in a Mathematica function?

If I have a function, for example: p1 = Plot[Evaluate[S[t]*10^-12 /. sol], {t, 20 10^-9, 49 10^-9}] and this function is setting options->Automatic so the function arguments are implicitly: p1 = Plot[Evaluate[S[t]*10^-12 /. sol], {t, 20 10^-9, 49…
Sean Bearden
  • 203
  • 1
  • 6
6
votes
1 answer

OptionsPattern[] taken as a Replacement Rule

I was trying to write my own plot function taking as unit size cm instead of points. I've tried Options[MyPlot] = Options[Plot]; SetOptions[MyPlot, ImageSize -> {8.22, 5.03}]; MyPlot[fun_, int_, opts_: OptionsPattern[]] := {fun, int, ImageSize ->…
Fabio
  • 1,357
  • 6
  • 13
5
votes
2 answers

Automatically return output using decimals instead of fractions

I have a mathematica file with an algorithm that feeds another program with data. my problem is that some times (randomly) the output is in fraction instead of decimal. The other program (java) does not read fractions, so I have to feed it with…
Fierce82
  • 543
  • 1
  • 4
  • 14
5
votes
1 answer

SetOptions not persistent between sessions

Let's say I decide I want all my axes to be colored red, so I do SetOptions[Plot,AxesStyle->Red] For the remainder of my session, I correctly get Options[Plot,AxesStyle] (* {AxesStyle->Red} *) But when I quit and subsequently reload MMA, I…
bmclaurin
  • 341
  • 1
  • 8
5
votes
0 answers

OptionValue: unknown option

I found sometimes, I need both OptionValue to get a customized default value and FilterRules in a function. Below is an illustration of the problem Options[myPlot] = {cc -> 10}; myPlot[f_, opts : OptionsPattern[]] := Module[{}, Plot[f[x]…
matheorem
  • 17,132
  • 8
  • 45
  • 115
5
votes
1 answer

Manipulations with options

I have two functions with options, for example f and g ClearAll[f,g,h] h::ioppf = "Value of option MaxIterations should be a positive integer."; g::method = "The Method option should be \"one\" or \"two\"."; h::fun = "The fun option should be \"f\"…
luck_liv
  • 209
  • 1
  • 10
4
votes
1 answer

How to set options in Option Inspector in notebooks by running commands?

It involves an order of magnitude more mouse clicks and visually searching text to set some option in the Option Inspector (which is a UX nightmare) than doing that in a notebook by running some command, or doing it in some menu or palette. In…
user13253
  • 8,666
  • 2
  • 42
  • 65
1
2