Skip to content

Commit

Permalink
Add try: except to create legend instead of colorbar
Browse files Browse the repository at this point in the history
  • Loading branch information
misi9170 committed Nov 15, 2024
1 parent 92141ef commit de37a37
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions floris/wind_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,12 @@ def plot(
)

# Configure the plot
ax.figure.colorbar(sm_ws, ax=ax, **legend_kwargs)
ax.figure.tight_layout()
try:
ax.figure.colorbar(sm_ws, ax=ax, **legend_kwargs)
ax.figure.tight_layout()
except TypeError:
ax.legend(reversed(rects), ws_bins, **legend_kwargs)
ax.figure.get_children()[-1].remove() # Remove the empty colorbar
ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi / 2.0)
ax.set_theta_zero_location("N")
Expand Down Expand Up @@ -1822,8 +1826,12 @@ def plot(
)

# Configure the plot
ax.figure.colorbar(sm_wv, ax=ax, **legend_kwargs)
ax.figure.tight_layout()
try:
ax.figure.colorbar(sm_wv, ax=ax, **legend_kwargs)
ax.figure.tight_layout()
except TypeError:
ax.legend(reversed(rects), var_bins, **legend_kwargs)
ax.figure.get_children()[-1].remove() # Remove the empty colorbar
ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi / 2.0)
ax.set_theta_zero_location("N")
Expand Down

0 comments on commit de37a37

Please sign in to comment.