set_bin_labels

ColorBar.set_bin_labels(bins, names, tick_lines='center', show_values=False)

Set the tick-labels of the colorbar to custom names with respect to a given set of bins.

The labels will be placed at the center of each bin.

This is most useful when using Maps.set_classify.UserDefined(bins=[...]) to classify the data with respect to custom bins.

Parameters:
  • bins (list) – A list of (right) bin-boundaries used to set the label-positions. (e.g. bins=[1, 2, 6] will result in labels located at [1.5 and 4])

  • names (list) –

    A list of names that should be used as labels.

    • The first name is assigned to the values smaller than bins[0]

    • Names 1 to β€œlen(bins)” are assigned to the intermediate bins

    • The β€œlen(bins) + 1” label is assigned to the values larger than bins[-1] (if not available a β€œ?” label will be used)

  • tick_lines (str) –

    Set appearance of the tick-lines

    • ”boundary”: show only (minor) tick lines at the bin-boundaries

    • ”center”: show only (major) tick lines at the center of the bins

    • ”both”: show both major and minor tick lines

    • None: don’t show any tick lines

    The default is β€œcenter”

  • show_values (bool) – If True, numerical values of the bin-boundaries will be shown as minor-tick labels. The default is False

Examples

>>> bins = [1, 2, 3]
>>> names = ["smaller than 1",
>>>          "between 1 and 2",
>>>          "between 2 and 3",
>>>          "larger than 3"]
>>>
>>> m.add_colorbar()
>>> m.label_bin_centers(bins, names)