Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotting enhancements #183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading