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

[routine/boxplot] Unit scaling argument

Repurpose sampling_period for unit scaling, as in
b6575f25

This commit addresses issue #20.
parent 6e194d72
No related branches found
No related tags found
No related merge requests found
...@@ -14,13 +14,13 @@ class _BoxplotPlotter(BasePlotter): ...@@ -14,13 +14,13 @@ class _BoxplotPlotter(BasePlotter):
self, self,
trace_df, trace_df,
trace_name, trace_name,
sampling_period, unit_scaling,
box_color, box_color,
xtick_step, xtick_step,
xlabel, xlabel,
plot_title, plot_title,
): ):
super().__init__(trace_name, sampling_period, xlabel, plot_title) super().__init__(trace_name, unit_scaling, xlabel, plot_title)
# Define attributes from arguments # Define attributes from arguments
self.trace_df = trace_df self.trace_df = trace_df
self.box_color = box_color self.box_color = box_color
...@@ -31,9 +31,11 @@ class _BoxplotPlotter(BasePlotter): ...@@ -31,9 +31,11 @@ class _BoxplotPlotter(BasePlotter):
# Define horizontal axis ticks and labels # Define horizontal axis ticks and labels
# hacky! -- redefine column names # hacky! -- redefine column names
trace_df.columns = trace_df.columns * self.sampling_period trace_df.columns = trace_df.columns * self.unit_scaling
self.fmt = ticker.FuncFormatter( self.fmt = ticker.FuncFormatter(
lambda x, pos: "{0:g}".format(x / (self.xtick_step / self.sampling_period)) lambda x, pos: "{0:g}".format(
x / (self.xtick_step / self.unit_scaling)
)
) )
def plot(self, ax): def plot(self, ax):
...@@ -47,14 +49,14 @@ class _BoxplotPlotter(BasePlotter): ...@@ -47,14 +49,14 @@ class _BoxplotPlotter(BasePlotter):
ax=ax, ax=ax,
) )
ax.xaxis.set_major_locator( ax.xaxis.set_major_locator(
ticker.MultipleLocator(self.xtick_step / self.sampling_period) ticker.MultipleLocator(self.xtick_step / self.unit_scaling)
) )
def boxplot( def boxplot(
trace_df, trace_df,
trace_name, trace_name,
sampling_period=5, unit_scaling=1,
box_color="b", box_color="b",
xtick_step=60, xtick_step=60,
xlabel="Time (min)", xlabel="Time (min)",
...@@ -64,7 +66,7 @@ def boxplot( ...@@ -64,7 +66,7 @@ def boxplot(
plotter = _BoxplotPlotter( plotter = _BoxplotPlotter(
trace_df, trace_df,
trace_name, trace_name,
sampling_period, unit_scaling,
box_color, box_color,
xtick_step, xtick_step,
xlabel, xlabel,
......
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