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 m.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)