Skip to content
Snippets Groups Projects
Commit 043caf5a authored by Arin Wongprommoon's avatar Arin Wongprommoon
Browse files

refactor(postproc): make birth event legend label an argument

WHY IS THIS CHANGE NEEDED?:
- when using single_birth_plot routine, user can change the label in
  the legend that indicates birth events

HOW DOES THE CHANGE SOLVE THE PROBLEM?:
- remove hard-coding of the 'birth event' label by making it an argument
  with the default of 'birth event'.
- this preserves backwards compatibility as i'm creating a new argument
  and the existing argument names are the same

WHAT SIDE EFFECTS DOES THIS CHANGE HAVE?:
- backwards compatibility: existing uses of this routine in scripts will
  produce 'budding event' in plots rather than 'birth event'; if a user
  wants to use 'birth event', they can simply define the argument
  birth_label='birth event'.

EVIDENCE THAT COMMIT WORKS:
- works with a random time series and a binary mask-like numpy array,
  and i can change the legend label

REFERENCES:
- issue #36
parent b206c48a
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ class _SingleBirthPlotter(_SinglePlotter):
birth_linestyle,
xlabel,
ylabel,
birth_label,
plot_title,
):
# Define attributes from arguments
......@@ -39,6 +40,7 @@ class _SingleBirthPlotter(_SinglePlotter):
self.birth_mask = birth_mask
self.birth_color = birth_color
self.birth_linestyle = birth_linestyle
self.birth_label = birth_label
def plot(self, ax):
"""Draw the line plots on the provided Axes."""
......@@ -47,7 +49,7 @@ class _SingleBirthPlotter(_SinglePlotter):
birth_mask_bool = self.birth_mask.astype(bool)
for occurence, birth_time in enumerate(trace_time[birth_mask_bool]):
if occurence == 0:
label = "birth event"
label = self.birth_label
else:
label = None
ax.axvline(
......@@ -71,6 +73,7 @@ def single_birth_plot(
birth_linestyle="--",
xlabel="Time (min)",
ylabel="Normalised flavin fluorescence (AU)",
birth_label="budding event",
plot_title="",
ax=None,
):
......@@ -101,6 +104,8 @@ def single_birth_plot(
x axis label.
ylabel : string
y axis label.
birth_label : string
label for budding event, 'budding event' by default.
plot_title : string
Plot title.
ax : matplotlib Axes
......@@ -128,6 +133,7 @@ def single_birth_plot(
birth_linestyle,
xlabel,
ylabel,
birth_label,
plot_title,
)
if ax is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment