0

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 ?

StarBucK
  • 2,164
  • 1
  • 10
  • 33
  • 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. – Bob Hanlon Sep 30 '20 at 14:32
  • @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). – StarBucK Sep 30 '20 at 14:36
  • 1
    See "Setting Up Functions with Optional Arguments" in the Tech Note Patterns – Bob Hanlon Sep 30 '20 at 14:50

1 Answers1

2

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.

Nate
  • 725
  • 3
  • 14