New answers tagged

3

The problem is that options not documented/released in System` context, are renamed to e.g. $CellContext`WholeCellGroupOpener. There is a more general topic about that: Programming scripts to create and modify stylesheets: problems with contexts So what your code does is creation of such option (you can check cell expression with Ctrl+Shift+E) which ...


6

I am not sure if the code you posted is literal but in any case you need to be using Alternative instead of Or, i.e. | instead of ||: SetOptions[#, {CellOpen -> False, WholeCellGroupOpener -> False}] & /@ Cells[EvaluationNotebook[], CellStyle -> ("Section" | "Subsection"), CellTags -> ("A" | "B")]


6

When you evaluate the statement opt=="def" it evaluates to True if opt really is "def", but it doesn't give False for any other object. Read the answer here to see why you need to use SameQ (===) instead of Equal (==), f[a_, opt_] := Module[{defOpt, opt2}, defOpt = {PlotLabel -> "Label"}; If[opt === "def", opt2 = defOpt, opt2 = Join[defOpt, opt]]; ...


4

To define a function with options, give it a set of defaults and use OptionsPattern in the definition. To use the value of a particular option in the function defintion, use OptionValue: Options[f] = {"ThisIsAnOption" -> False, SoIsThis -> 1}; f[a_, opt : OptionsPattern[]] := (If[OptionValue["ThisIsAnOption"], Print[{opt}]]; a + ...


4

Framework We can create a package providing framework for option value validation. BeginPackage["OptionsValidation`"]; Unprotect["`*"]; ClearAll["`*"] CheckOption::usage = " CheckOption[f, name, value] \ checks validity, of given option value, as option of f symbol, with given \ name. Returns True if option is valid, otherwise returns expression ...


7

PlotPoints guarantees a number of points that will be plotted. MaxRecursion states the maximum recursion, which might not be needed or used in a given plot. If I'm plotting a large number of functions—some simple, some complex—then I use MaxRecursion so as to speed the plotting of "simple" graphs. Moreover, PlotPoints generally places the points equally ...


1

You can find the actual default style information using this: Charting`ResolvePlotTheme["Default", BarChart] {{0.71, "DefaultChartBaseStyle" -> RGBColor[0.982864, 0.7431472, 0.3262672]}, {0.1, GridLinesStyle -> Directive[ GrayLevel[0.5, 0.4]]}, {0.71, "ChartDefaultStyle" -> (Blend[ Lighter[System`PlotThemeDump`$ThemeDefaultGradient, ...



Top 50 recent answers are included