Hot answers tagged

46

I use this function getList[name_String] := Module[{options, idx}, options = Names[name <> "`*"]; options = ToExpression /@ options; options = {#, Options[#]} & /@ options; idx = Range[Length[options]]; options = {#[[1]], TableForm[#[[2]]]} & /@ options; options = Insert[options[[#]], #, 1] & /@ idx; options = Insert[...


28

Yes, it is possible: The idea is to look at the underlying cell expressions in the documentation for those string property tables. As I said already in my comment above, basically we have two different situations here: the trend since Mathematica V6 that many options are not symbols any more but rather strings. function arguments, that are given as ...


27

Thanks for asking this question; I might not have discovered this customizable area without it. The auto-completion option values are automatically loaded on Front End start from: FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "SystemResources", "FunctionalFrequency", "OptionValues"}] This directory contains a series of Package (.m) ...


24

Version 12.2 In version 12.2, use the new function WithCleanup[]: With[{plotOptions = Options[Plot]}, WithCleanup[SetOptions[Plot, PlotStyle -> Green], Plot[Sin[x], {x, -π, π}], SetOptions[Plot, plotOptions]]] which is a direct replacement of the older undocumented function described below. Older versions Usual ...


23

The complete list of possible methods is given by Optimization`NMinimizeDump`$Methods: Optimization`NMinimizeDump`$Methods (* -> {Automatic, DifferentialEvolution, NelderMead, SimulatedAnnealing, RandomSearch, NonlinearInteriorPoint} *) As you can see, there is one undocumented method: NonlinearInteriorPoint. The probable reason for its being ...


21

Here is what I do in such cases ([edit from 01/10/2020 - apparently, this technique has been exposed on this site earlier, at least partially, in this nice answer by Mr.Wizard - which I definitely read but must have forgotten at the time of posting my answer]) : ClearAll[g, f]; Options[f] = {optA -> 1, optB -> 1, optC -> 1}; f[x_, opts : ...


19

Let me first answer your second question, since I can only guess about the main question: I also observed that the syntax colouring (version 10, windows 7) suggests that Trace can be used with only two arguments. It's really just the coloring that goes wrong and has nothing to do with functionality. You can see that it is not even related to ...


19

Normally I like to use On and Off for this kind of tracing as it is easy to set up without modifying any symbols. However, it does not immediately work in this case: On[Roots] Solve[x^3 - 2 x + 12 == 0, x]; Off[] This does not produce any trace messages. Something must be using Quiet to suppress them. We can check this hypothesis: On[Quiet] Solve[x^3 - ...


19

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. With[{nb = EvaluationNotebook[]}, DynamicModule[{wm, ws}, CreateWindow[ PaletteNotebook[ {DynamicWrapper[TextCell["Click OK to close", Orange], ...


18

I don't know why no one mentioned this, but all you have to do is to use a special form of OptionsPattern: pfunc[x0_, plotopts : OptionsPattern[{Plot, pfunc}]] := your-code where inside OptionsPattern go all sub-functions you need, in a list. Now everything is fine and dandy. This has been explained already in this answer of Mr. Wizard, so this answer and ...


18

After some spelunking it appears I have an answer and solution: the behavior is as intended, and it is controlled by a Method option "AllowMicroRanges". ListLinePlot[dat, PlotRange -> Full, Method -> {"AllowMicroRanges" -> #} ] & /@ {True, False} It seems this option may also be given directly, outside of Method, but if you wish to ...


17

Introduction What are good (robust?, simple?, efficient?) patterns for doing this kind of code-switching? This answer outlines a development strategy that can produce robust and extensible method option handling. Conceptually and development-wise, it is not that simple, but it has been successfully applied in large software projects with complicated ...


17

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 changes to a symbol to be made, including changes to Options. For example, Internal`InheritedBlock[{Plot}, SetOptions[Plot, PlotStyle -> Red, Frame -> True]; Plot[Sin[x], {x, 0, 2 Pi}] ] ...


17

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 such a function myPlot? Below I will try to give a complete guide on how to do this. There are two common approaches: The default values for Plot-specific options will be taken directly from Plot....


16

As Mr.Wizard indicated, you can also reconstruct the plot using the data. Here is an example: restylePlot2[p_, op : OptionsPattern[ListLinePlot]] := ListLinePlot[Cases[Normal@p, Line[x__] :> x, ∞], op, Options[p]] then we can set the style as we do in plot. For example restylePlot2[myplot2, PlotStyle -> {{Green, Thick, Dashed}, {Thickness[...


16

As far as I know there is no documented list of Method options for ContourPlot and DensityPlot. If you want to experiment there is a large list of strings in Charting`CommonDump`$VisualizationMethodOptions to have a look at. Some of these are option settings, some are option values. Most seem to have no effect on a simple ContourPlot and probably apply to ...


16

Padding Without padding of any kind the over-all aspect ratio and element (primitive) aspect ratio are the same and as specified: g0 = Graphics[{Opacity[0.5, Red], Rectangle[{0, 0}, {3, 2}]}, AspectRatio -> 2/3, Background -> GrayLevel[0.8], PlotRangePadding -> 0] (There is a one pixel discrepancy along the right edge where the background ...


16

The choices allowed for "ParametricSensitivity" can be seen from the following error message ParametricNDSolveValue[{y'[t] == 1, y[0] == a}, y[1], {t, 1}, a, Method -> {"ParametricSensitivity" -> "?"}]; (* ParametricNDSolveValue::bdsmtd: Method ? for solution stage ParametricSensitivity is not one of {Automatic, None, ForwardSensitivity, ...


15

I was hesitating but it seems some people find this information useful. SetOptions[Manipulator, Appearance -> "Labeled"]; Manipulate[{a, b, c}, {a, 1, 10}, {b, 1, 10}, {c, 1, 10}] But, still, I do not consider it the full answer. Like it is stated, it affects only Manipulator, the default control used by Manipulate for domains that are suited ...


15

NIntegrate Method options There are many Method settings to use in NIntegrate and many but not all of their suboptions are documented the tutorial on NIntegrate. Some of these may be found by ?NIntegrate`StrategiesDump`*Options Others may be found by ?NIntegrate`StrategiesDump`*Properties Note in the case shown, the options are the same as the Method ...


15

A little bit tricky because it is not supposed to work: ScallingFunctions are documented since V11 but this works for V10 and maybe erlier versions. Plot[x^2, {x, 0, 3}, ScalingFunctions -> {Identity, "Reverse"}, PlotRange -> {{0, 4}, {-10, 0}}, AxesStyle -> {Arrowheads@.05, Arrowheads[{-.05, 0}]}] How ...


15

Thanks to this answer for the gradient filling you can do the following: sign[text_, xc_, size_] := Graphics[{FaceForm[White], EdgeForm[Thin], Polygon[{{0, 0}, {.25, -.40}, {2.5, -.40}, {2.5, .40}, {.25, .40}}], Style[Text[Round[text, .01], {1.25, 0}], size, Black]}, ImageSize -> Scaled[xc]] gradientBackground = With[{bottomColor = Black,...


15

As already mentioned, options are accessed via: Method -> {"NeuralNetwork", "L2Regularization" -> 0.12, "HiddenLayers" -> {4, 3, 3}} To manually set the activation functions of the first and second hidden layers: "HiddenLayers"-> {{4, "RectifiedLinear"}, {3, "Tanh"}, 3} Currently, the following activation functions are supported: {"...


15

You must use opts : OptionsPattern[] and not opts_ : OptionsPattern[]. The : character has a double role: it can indicate a pattern name or an optional argument. If the left-hand-side is a symbol then it indicates a pattern name, otherwise it indicates an optional argument. Examples: a_ is a Blank named a. a : _ is a blank named a using : syntax. a_ : ...


14

Several ways to make the opener icon for cell groups visible: You can set the ShowGroupOpener to True for the current notebook using SetOptions[EvaluationNotebook[], ShowGroupOpener -> True] If you want the icon to show in all notebooks in the current front-end session use SetOptions[$FrontEndSession, ShowGroupOpener -> True] To get the opener ...


14

At least Method -> {"NeuralNetwork", "L2Regularization" -> 0.01, "HiddenLayers" -> {4, 3, 3}} seems to work. "L1Regularization" doesn't seem to be settable. Haven't found out about activation functions yet. Update More options can be found using Options@MachineLearning`PackageScope`NeuralNetworkPredictor {"BinaryEncoder" -> "Identity", "...


14

I have no idea if the old syntax was removed for a reason, but normal behaviour can be returned with the following workaround: Unprotect[Visualization`Utilities`FrameTicksQ]; Visualization`Utilities`FrameTicksQ[{ _?Visualization`Utilities`OptionsDump`tickListQ, _?Visualization`Utilities`OptionsDump`tickListQ, _?Visualization`Utilities`OptionsDump`...


14

Fortunately there is a solution but it appears to be undocumented and takes a bit of guess work. The magic is: FilledCurveBoxOptions -> {Method -> {"SplinePoints" -> (* integer value *)}} This may be set globally or for a Notebook: SetOptions[InputNotebook[], FilledCurveBoxOptions -> {Method -> {"SplinePoints" -> 30}}] (Use $FrontEnd ...


14

When different plots use conflicting options, Show uses the first one listed. So, here it is using the PlotRange of the first graphics instance. Use Show[Table[ListPlot[{{i, i^2}}], {i, 1, 10}], PlotRange -> All] instead to see all the points. Further Explanation To see more clearly what is happening, consider the InputForm (as suggested by ...


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