Skip to content

Commit

Permalink
Fix colorbar in PlotSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsvu committed Sep 3, 2024
1 parent 2da887f commit b319055
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Visualization/Python/PlotSlice.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def coord_axis(vec):
plt.gca().set_aspect("equal")
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.colorbar(matplotlib.cm.ScalarMappable(norm=norm), ax=ax)
cbar = plt.colorbar(matplotlib.cm.ScalarMappable(norm=norm), ax=ax)
time_label = plt.annotate(
"",
xy=(0, 0),
Expand Down Expand Up @@ -212,6 +212,8 @@ def plot_slice(obs_id, time):
contours_filled, colors="white", linewidths=0.5, alpha=0.6
)
time_label.set_text(f"t = {time:g}")
if norm is None:
cbar.update_normal(contours_filled)
return contours_filled.collections + contours.collections

# Plot a static slice and return early
Expand Down

0 comments on commit b319055

Please sign in to comment.