Skip to main content
26 votes

SetOptions locally?

Version 12.2 In version 12.2, use the new function WithCleanup[]: ...
21 votes
Accepted

Inheriting Options?

Let us assume that you are designing a function which can take its own unique options, but also shares option names with Plot. What is the best way to implement ...
Szabolcs's user avatar
  • 236k
19 votes
Accepted

Creating a simple Dock Cell that Fades In when Cursor Hover Over It

Edit: Fading overlay window In order to get a top dock element with real transparency, one can create a window that overlays the current notebook window and adjusts its position together with it. <...
Karsten7's user avatar
  • 27.5k
17 votes

SetOptions locally?

I have used several methods, including the ones in the other answers. I have found that the simplest method is Internal`InheritedBlock as it allows for temporary ...
rcollyer's user avatar
  • 34.1k
17 votes

Is a list of all graph layouts available?

ResourceFunction["QueryCodeCompletion"]["GraphLayout","KernelSymbol","Graph","InOptionValuePosition"]
yode's user avatar
  • 26.9k
15 votes

OptionsPattern[] taken as a Replacement Rule

You must use opts : OptionsPattern[] and not opts_ : OptionsPattern[]. The : character has ...
Szabolcs's user avatar
  • 236k
15 votes
Accepted

How to check the validity of an option value

Implementation This is indeed an important problem. It is usually best to have a separate function testing various options. Here is the solution I propose: a wrapper that would factor out the testing ...
Leonid Shifrin's user avatar
15 votes
Accepted

Bulletproofing packages against SetOptions of built-ins

The approach This seems to be a good case for applying some run-time metaprogramming / introspection. The idea would be to patch the already constructed definitions after they have been created, at ...
Leonid Shifrin's user avatar
13 votes
Accepted

How to extract the AspectRatio of a plot?

For example: p1 = Plot[Sin[x], {x, 0, π}] AbsoluteOptions[p1, AspectRatio] {AspectRatio -> 0.618034} If this number looks familiar, it is because the default <...
Syed's user avatar
  • 56k
12 votes
Accepted

Confused by the opts : OptionsPattern[ ] pattern

Re 1: As documented in Operator Input Forms, colon represents two different operations: symb:expr Pattern[symb, expr] patt:expr Optional[patt, expr] If you ...
Itai Seggev's user avatar
  • 14.2k
12 votes
Accepted

What is Hessian?

The Mathematica documentation for FindMaxValue includes the example ...
mikado's user avatar
  • 16.8k
12 votes

SetOptions locally?

Just define your options as sequence held in a local variable. ...
m_goldberg's user avatar
  • 108k
12 votes

What are the possible Method option values for plotting functions?

I found one: For ParametricPlot3D (and Plot, Plot3D), ...
Michael E2's user avatar
  • 239k
12 votes

Are Mathematica commands always supposed to check that Method -> name is valid?

The other answer is completely correct (see my comment), but let me add some context. For algorthmic functions, it is generally the case that we validate the method options and issue messages/fail (...
Itai Seggev's user avatar
  • 14.2k
12 votes
Accepted

Option Lighting in the Show function does not work

Update: This is yet another case of automatic PlotTheme settings injecting directives that override the user-specified ones. So, a much easier fix is to add the ...
kglr's user avatar
  • 399k
12 votes
Accepted

OptionValue doesn't work if a local variable has the same name as the function itself

Looks like a variable capture, caused by the macro-like expansion mechanism of OptionValue , which happens before the r.h.s. of the function gets evaluated. What ...
Leonid Shifrin's user avatar
12 votes
Accepted

Which functions use a given option?

You can use WolframLanguageData with the property "SymbolsUsingAsOption" for this: ...
Lukas Lang's user avatar
  • 34.2k
11 votes
Accepted

More Ticks::ticks errors in AbsoluteOptions in v10

This is what I believe the situation to be. AbsoluteOptions uses FullAxes under the hood. It turns out that ...
Carl Woll's user avatar
  • 131k
11 votes

PenaltyFunction Option in NMinimize

As noted in the OP, "PenaltyFunction" has the form pf[..., step] where the first argument is constructed from the ...
Michael E2's user avatar
  • 239k
11 votes
Accepted

Are Mathematica commands always supposed to check that Method -> name is valid?

I would expect a fully implemented/documented function to check the validity of the specified Method; however, since ...
Bob Hanlon's user avatar
  • 160k
11 votes
Accepted

How to delete an option from a notebook

You can use NotebookGet/NotebookPut. Here is a function that does this: ...
Carl Woll's user avatar
  • 131k
11 votes

Is a list of all graph layouts available?

@yode's answer is the better choice, but since it missed some options, here is a manual one that works in this particular case. The question you asked was discussed during a Live CEOing session (I ...
Ben Izd's user avatar
  • 9,474
10 votes

Options for the function 'Classify'

Take the first example from the documentation trainingset = {1 -> "A", 2 -> "A", 3.5 -> "B", 4 -> "B"}; and use a nearest neighbor classifier to find ...
Sascha's user avatar
  • 8,499
10 votes

SetOptions locally?

This is a simple solution. The idea is to save the Plot options on entry, and restore it on leaving the module to whatever it was ...
Nasser's user avatar
  • 147k
10 votes
Accepted

Increasing notebook magnification pushes output onto a new line

You can increase the CellMargins for the styles "Input" and "Output" in your style sheet to accommodate the increased size of the cell labels. For example, the ...
Carl Woll's user avatar
  • 131k
10 votes
Accepted

How to programmatically enable/disable a slider in Manipulate?

Enabled can be useful here; the Slider will not disappear but it will be "grayed out." ...
Mr.Wizard's user avatar
  • 272k
10 votes

Except @ OptionsPattern[] affects OptionValue

Recall that OptionValue is a "magic" symbol with nonstandard behavior. The expression OptionValue["bar"] "by magic" gets its ...
Mr.Wizard's user avatar
  • 272k
10 votes
Accepted

Using a pure function as an option of a function

Use f[2, "Func" -> (# + 2) &] // FullForm to discover that operator precedence has bitten you. You have written effectively ...
Patrick Stevens's user avatar
9 votes

Creating a NearestFunction that returns an index

In version 11, you can also use pts -> "Index": ...
kglr's user avatar
  • 399k

Only top scored, non community-wiki answers of a minimum length are eligible