Skip to content

Commit

Permalink
Polygon plots: improve handling of colorbar label
Browse files Browse the repository at this point in the history
- Now handles cases when there is no variable name, e.g. when you plot a derived variable like ds["Ne"] * ds["Te"]
  • Loading branch information
mikekryjak committed May 25, 2024
1 parent 93dc38e commit afbeaf0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions xbout/plotting/plotfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,13 +932,16 @@ def plot2d_polygon(
if vmax is None:
vmax = np.nanmax(da.max().values)

if colorbar_label is None:
if colorbar_label == None:
if "short_name" in da.attrs:
colorbar_label = da.short_name
else:
colorbar_label = da.attrs["short_name"]
elif da.name != None:
colorbar_label = da.name
if "units" in da.attrs:
colorbar_label += f" [{da.units}]"
else:
colorbar_label = ""

if "units" in da.attrs:
colorbar_label += f" [{da.attrs['units']}]"

if "Rxy_lower_right_corners" in da.coords:
r_nodes = [
Expand Down

0 comments on commit afbeaf0

Please sign in to comment.