MCPcopy Create free account
hub / github.com/danjgale/surfplot / _set_colorbar_labels

Function _set_colorbar_labels

surfplot/plotting.py:153–166  ·  view source on GitHub ↗

Add colorbar labels to drawn colorbar

(cbar, label, location, fontsize=10, rotation=None)

Source from the content-addressed store, hash-verified

151
152
153def _set_colorbar_labels(cbar, label, location, fontsize=10, rotation=None):
154 """Add colorbar labels to drawn colorbar"""
155 valid_locations = ['top', 'bottom', 'left', 'right']
156 if location not in valid_locations:
157 raise ValueError(f"`location` must be one of {valid_locations}")
158
159 rotation, ha, va = _set_label_positions(location, rotation)
160 label_args = dict(rotation=rotation, ha=ha, va=va, fontsize=fontsize)
161
162 if location in ['top', 'bottom']:
163 cbar.ax.set_ylabel(label, **label_args)
164 else:
165 cbar.ax.set_title(label, pad=10, **label_args)
166 return cbar
167
168
169class Plot(object):

Callers 1

_add_colorbarsMethod · 0.85

Calls 1

_set_label_positionsFunction · 0.85

Tested by

no test coverage detected