// Get start and end times for the plot
start = convert_to_timestamp(start)
end = convert_to_timestamp(end)
if start is None or end is None:
timeframe_for_group = self.get_timeframe()
if start is None:
start = timeframe_for_group.start
if end is None:
end = timeframe_for_group.end
timeframe = TimeFrame(start, end)
// Calculate the resolution for the x axis
duration = (end - start).total_seconds()
secs_per_pixel = int(round(duration / width))
// Define a resample function
resample_func = lambda df: pd.DataFrame.resample(
df, rule="{:d}S".format(secs_per_pixel))
// Load data and plot each meter
for meter in self.meters:
power_series = meter.power_series_all_data(
sections=[timeframe], preprocessing=[Apply(func=resample_func)])
ax = plot_series(power_series, ax=ax, label=meter.appliance_label())
if plot_legend:
plt.legend()