| 139 | |
| 140 | |
| 141 | class Colormapping(Controls): |
| 142 | clim = param.Range( |
| 143 | label='Colorbar Limits (clim)', |
| 144 | doc=""" |
| 145 | Upper and lower limits of the colorbar.""", |
| 146 | ) |
| 147 | |
| 148 | cnorm = param.Selector( |
| 149 | label='Colorbar Normalization (cnorm)', |
| 150 | default='linear', |
| 151 | objects=['linear', 'log', 'eq_hist'], |
| 152 | ) |
| 153 | |
| 154 | color = param.String(default=None) |
| 155 | |
| 156 | colorbar = param.Boolean(default=None) |
| 157 | |
| 158 | cmap = param.Selector(default=DEFAULT_CMAPS['linear'], label='Colormap', objects=CMAPS) |
| 159 | |
| 160 | rescale_discrete_levels = param.Boolean(default=True) |
| 161 | |
| 162 | symmetric = param.Boolean( |
| 163 | default=False, |
| 164 | doc=""" |
| 165 | Whether the data are symmetric around zero.""", |
| 166 | ) |
| 167 | |
| 168 | _widgets_kwargs = {'clim': {'placeholder': '(min, max)'}} |
| 169 | |
| 170 | def __init__(self, data, **params): |
| 171 | super().__init__(data, **params) |
| 172 | if 'symmetric' not in params: |
| 173 | self.symmetric = self.explorer._converter._plot_opts.get('symmetric', False) |
| 174 | |
| 175 | @property |
| 176 | def colormapped(self): |
| 177 | if self.explorer.kind in _hvConverter._colorbar_types: |
| 178 | return True |
| 179 | return self.color is not None and self.color in self._data |
| 180 | |
| 181 | @param.depends('color', 'explorer.kind', 'symmetric', watch=True) |
| 182 | def _update_coloropts(self): |
| 183 | if not self.colormapped or self.cmap not in list(DEFAULT_CMAPS.values()): |
| 184 | return |
| 185 | if self.explorer.kind in _hvConverter._colorbar_types: |
| 186 | key = 'diverging' if self.symmetric else 'linear' |
| 187 | self.colorbar = True |
| 188 | elif self.color in self._data: |
| 189 | kind = self._data[self.color].dtype.kind |
| 190 | if kind in 'OSU': |
| 191 | key = 'categorical' |
| 192 | elif self.symmetric: |
| 193 | key = 'diverging' |
| 194 | else: |
| 195 | key = 'linear' |
| 196 | else: |
| 197 | return |
| 198 | self.cmap = DEFAULT_CMAPS[key] |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…