0
$\begingroup$

In this post is given the following code:

ContourPlot[Sin[x] Cos[y], {x, 0, 2 Pi}, {y, 0, 2 Pi}, 
  Contours -> {Automatic, 10}, ColorFunction -> "Rainbow", 
  PlotLegends -> BarLegend[Automatic, None, 
   "Ticks" -> {{-1, "cold"}, {0, "ok"}, {1, "hot"}}]]

As you can see, BarLegend has 5 parameters. However, on the documentation we see that BarLegends can only take one or two parameters:

BarLegend[cf]
BarLegend[{cf,{min,max}}]
BarLegend[cf,contours]

What am I understanding wrong with the documentation ?

$\endgroup$
3
  • $\begingroup$ The BarLegend shown has two parameters and one option. The form matches the third example. The colorfunction (cf) is Automatic (the default), the contours on the legend are suppressed (None) , and the option is specifying the custom ticks. $\endgroup$
    – Bob Hanlon
    Commented Sep 30, 2020 at 14:32
  • $\begingroup$ @BobHanlon probably a basic and stupid question but then as soon as I have "A -> B" written in the call of a function it is usually an option ? And the option are never listed in the parameters list (it is conceptually not considered as parameters by the doc). $\endgroup$
    – StarBucK
    Commented Sep 30, 2020 at 14:36
  • 1
    $\begingroup$ See "Setting Up Functions with Optional Arguments" in the Tech Note Patterns $\endgroup$
    – Bob Hanlon
    Commented Sep 30, 2020 at 14:50

1 Answer 1

2
$\begingroup$

In Mathematica, many functions have what are called options. In the documentation there is a section below the function definitions called "Details and Options" that explains the valid options for a function. Options are as the name suggests, optional parameters that can be given to a function. These control anything from formatting the output, to choosing the strategy the function should use. These are not listed in the parameters since options are not required to use the function, as well, you can use any number of options and they can occur in any order at the end of a function call. Options are Mathematica features that are very flexible and provide a lot of customization choices to users.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.