Skip to content

Commit e4f7900

Browse files
apatlpoAurelien Ponte
and
Aurelien Ponte
authored
implement a more threadsafe call to colorbar (#3944)
Co-authored-by: Aurelien Ponte <[email protected]>
1 parent 1eedc5c commit e4f7900

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

xarray/plot/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,15 @@ def _is_numeric(arr):
581581

582582

583583
def _add_colorbar(primitive, ax, cbar_ax, cbar_kwargs, cmap_params):
584-
plt = import_matplotlib_pyplot()
584+
585585
cbar_kwargs.setdefault("extend", cmap_params["extend"])
586586
if cbar_ax is None:
587587
cbar_kwargs.setdefault("ax", ax)
588588
else:
589589
cbar_kwargs.setdefault("cax", cbar_ax)
590590

591-
cbar = plt.colorbar(primitive, **cbar_kwargs)
591+
fig = ax.get_figure()
592+
cbar = fig.colorbar(primitive, **cbar_kwargs)
592593

593594
return cbar
594595

0 commit comments

Comments
 (0)