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)