Skip to content

Commit afbeaf0

Browse files
committed
Polygon plots: improve handling of colorbar label
- Now handles cases when there is no variable name, e.g. when you plot a derived variable like ds["Ne"] * ds["Te"]
1 parent 93dc38e commit afbeaf0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

xbout/plotting/plotfuncs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -932,13 +932,16 @@ def plot2d_polygon(
932932
if vmax is None:
933933
vmax = np.nanmax(da.max().values)
934934

935-
if colorbar_label is None:
935+
if colorbar_label == None:
936936
if "short_name" in da.attrs:
937-
colorbar_label = da.short_name
938-
else:
937+
colorbar_label = da.attrs["short_name"]
938+
elif da.name != None:
939939
colorbar_label = da.name
940-
if "units" in da.attrs:
941-
colorbar_label += f" [{da.units}]"
940+
else:
941+
colorbar_label = ""
942+
943+
if "units" in da.attrs:
944+
colorbar_label += f" [{da.attrs['units']}]"
942945

943946
if "Rxy_lower_right_corners" in da.coords:
944947
r_nodes = [

0 commit comments

Comments
 (0)