Skip to content

Commit

Permalink
add color bar and scatter option
Browse files Browse the repository at this point in the history
  • Loading branch information
jrob93 committed Nov 19, 2024
1 parent 7da879f commit dc0133a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/adler/utilities/plotting_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def plot_errorbar(
x_plot="phaseAngle",
y_plot="reduced_mag",
xerr_plot="magErr",
c_plot=None,
fig=None,
label_list=None,
col_list=None,
Expand All @@ -25,6 +26,8 @@ def plot_errorbar(
Name of the AdlerPlanetoid attribute to be plotted on the y axis
xerr_plot: str
Name of the AdlerPlanetoid attribute for the x axis uncertainties
c_plot: str
Name of the AdlerPlanetoid attribute used for the colour scale
fig: matplotlib.figure.Figure
Optional, pass an existing figure object to be added to
label_list: list
Expand Down Expand Up @@ -58,7 +61,6 @@ def plot_errorbar(
obs_filt = planetoid.observations_in_filter(filt)
x = getattr(obs_filt, x_plot)
y = getattr(obs_filt, y_plot)
xerr = getattr(obs_filt, xerr_plot)

# label the errorbars?
if label_list is not None:
Expand All @@ -67,13 +69,24 @@ def plot_errorbar(
l = None

# select colours?
if col_list is not None:
if (col_list is not None) and (c_plot is None):
c = col_list[i]
elif c_plot is not None:
c = getattr(obs_filt, c_plot)
# TODO: use kwargs to pass the cmap?
else:
c = None

# plot the errorbars
ax1.errorbar(x, y, xerr, color=c, fmt="o", label=l)
if xerr_plot is not None:
# plot the errorbars
xerr = getattr(obs_filt, xerr_plot)
s1 = ax1.errorbar(x, y, xerr, color=c, fmt="o", label=l) # TODO: get cmap working with errorbar
else:
# just plot scatter
s1 = ax1.scatter(x, y, c=c, label=l)

if c_plot is not None:
cbar1 = plt.colorbar(s1)

# save the figure?
if filename:
Expand Down

0 comments on commit dc0133a

Please sign in to comment.