Closed kafitzgerald closed 9 months ago
Thanks for catching this @kafitzgerald
Looks like it's an issue with the logic we're using for setting the default colorbar label.
This leads to a duplication of clim
being passed into the plotting routines (one in the variable, one is still in the kwargs)
Thanks for the speedy response!
Version
2024.01.1
How did you install UXarray?
Conda
What happened?
I'm getting an error when I try to feed a new colorbar label kwarg to
.plot.rasterize()
.For example in the UXarray Pythia Cookbook:
uxds["bottomDepth"].plot.rasterize(clabel='my new colorbar label')
Here's the full error:
``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[16], line 1 ----> 1 uxds["bottomDepth"].plot.rasterize(clabel='my new colorbar label') File /srv/conda/envs/notebook/lib/python3.11/site-packages/uxarray/plot/accessor.py:360, in UxDataArrayPlotAccessor.rasterize(self, method, backend, exclude_antimeridian, pixel_ratio, dynamic, precompute, projection, width, height, colorbar, cmap, aggregator, interpolation, npartitions, cache, override, size, **kwargs) 315 @functools.wraps(dataarray_plot.rasterize) 316 def rasterize( 317 self, (...) 335 **kwargs, 336 ): 337 """Raster plot of a data variable residing on an unstructured grid 338 element. 339 (...) 357 or run holoviews.help(holoviews.operation.datashader.rasterize). 358 """ --> 360 return dataarray_plot.rasterize( 361 self._uxda, 362 method=method, 363 backend=backend, 364 exclude_antimeridian=exclude_antimeridian, 365 pixel_ratio=pixel_ratio, 366 dynamic=dynamic, 367 precompute=precompute, 368 projection=projection, 369 width=width, 370 height=height, 371 colorbar=colorbar, 372 cmap=cmap, 373 aggregator=aggregator, 374 interpolation=interpolation, 375 npartitions=npartitions, 376 cache=cache, 377 override=override, 378 size=size, 379 **kwargs, 380 ) File /srv/conda/envs/notebook/lib/python3.11/site-packages/uxarray/plot/dataarray_plot.py:166, in rasterize(uxda, method, backend, exclude_antimeridian, pixel_ratio, dynamic, precompute, projection, width, height, colorbar, cmap, aggregator, interpolation, npartitions, cache, override, size, **kwargs) 147 raster = _point_raster( 148 uxda=uxda, 149 backend=backend, (...) 163 **kwargs, 164 ) 165 elif method == "polygon": --> 166 raster = _polygon_raster( 167 uxda=uxda, 168 backend=backend, 169 exclude_antimeridian=exclude_antimeridian, 170 dynamic=dynamic, 171 precompute=precompute, 172 width=width, 173 height=height, 174 colorbar=colorbar, 175 cmap=cmap, 176 aggregator=aggregator, 177 interpolation=interpolation, 178 pixel_ratio=pixel_ratio, 179 cache=cache, 180 override=override, 181 **kwargs, 182 ) 183 else: 184 raise ValueError(f"Unsupported method: {method}.") File /srv/conda/envs/notebook/lib/python3.11/site-packages/uxarray/plot/dataarray_plot.py:380, in _polygon_raster(uxda, backend, exclude_antimeridian, pixel_ratio, dynamic, precompute, width, height, colorbar, cmap, aggregator, interpolation, xlabel, ylabel, cache, override, **kwargs) 377 elif backend == "bokeh": 378 # use holoviews bokeh backend 379 hv.extension("bokeh") --> 380 raster = hds_rasterize( 381 hv_polygons, 382 pixel_ratio=pixel_ratio, 383 dynamic=dynamic, 384 precompute=precompute, 385 aggregator=aggregator, 386 interpolation=interpolation, 387 ).opts( 388 width=width, 389 height=height, 390 colorbar=colorbar, 391 cmap=cmap, 392 xlabel=xlabel, 393 ylabel=ylabel, 394 clabel=clabel, 395 **kwargs, 396 ) 398 else: 399 raise ValueError( 400 f"Invalid backend selected. Expected one of ['matplotlib', 'bokeh'] but received {backend}." 401 ) TypeError: Opts(axiswise=False, cmap='kbc_r', framewise=False) got multiple values for keyword argument 'clabel' ```What did you expect to happen?
A new colorbar label and no error.
Can you provide a MCVE to repoduce the bug?
No response