Add colorbar labels to drawn colorbar
(cbar, label, location, fontsize=10, rotation=None)
| 151 | |
| 152 | |
| 153 | def _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 | |
| 169 | class Plot(object): |
no test coverage detected