Skip to content

Commit

Permalink
Add option for not adding a colorbar on a scatter_plot
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaze committed Feb 18, 2025
1 parent fe28358 commit 3a2fb14
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions argopy/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def scatter_plot(
vmin=None,
vmax=None,
s=4,
cbar: bool = False,
bgcolor="lightgrey",
):
"""A quick-and-dirty parameter scatter plot for one variable"""
Expand Down Expand Up @@ -664,8 +665,9 @@ def get_vlabel(this_ds, this_v):
m = ax.scatter(x, y, c=c, cmap=cmap, s=s, vmin=vmin, vmax=vmax)
ax.set_facecolor(bgcolor)

cbar = fig.colorbar(m, shrink=0.9, extend="both", ax=ax)
cbar.ax.set_ylabel(get_vlabel(ds, this_param), rotation=90)
if cbar:
cbar = fig.colorbar(m, shrink=0.9, extend="both", ax=ax)
cbar.ax.set_ylabel(get_vlabel(ds, this_param), rotation=90)

ylim = ax.get_ylim()
if "PRES" in this_y:
Expand All @@ -685,4 +687,8 @@ def get_vlabel(this_ds, this_v):
ax.set_xlabel(get_vlabel(ds, this_x))
ax.set_ylabel(get_vlabel(ds, this_y))

return fig, ax
if cbar:
return fig, ax, m, cbar
else:
return fig, ax, m

0 comments on commit 3a2fb14

Please sign in to comment.