diff --git a/requirements.txt b/requirements.txt index 1e0b6f5..a14cdec 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ numpy requests pandas -matplotlib sphinx \ No newline at end of file diff --git a/timeseriesql/tests/timeseries_test.py b/timeseriesql/tests/timeseries_test.py index a8d88d6..cb7f98e 100644 --- a/timeseriesql/tests/timeseries_test.py +++ b/timeseriesql/tests/timeseries_test.py @@ -460,10 +460,4 @@ def test_invalid_index(self): # out of bounds stop date index out_of_bounds_date = np.datetime64(int(t1.time[0] - 86400), "s") new_t = t1[out_of_bounds_date:np.timedelta64(3, "m")] - self.assertEqual(len(new_t), 0) - - def test_matplotlib(self): - t1, t2, t3 = self.basic_timeseries - - t1.plot(legend=True) - self.assertEqual(1, len(plt.get_fignums())) + self.assertEqual(len(new_t), 0) \ No newline at end of file diff --git a/timeseriesql/timeseries.py b/timeseriesql/timeseries.py index 8adc291..cf8a0bf 100644 --- a/timeseriesql/timeseries.py +++ b/timeseriesql/timeseries.py @@ -604,93 +604,6 @@ def rolling_window(self, size, stepsize=1): collection.chunks = (TimeChunk(slice(i, i+size), slice(None, None, None)) for i in range(0, len(self)-size+1, stepsize)) return collection - def plot(self, ax=None, legend=True, **kwargs): - """Plot charts using sane time series defaults with Matplotlib. - - Parameters - ---------- - ax : matplotlib.axes.Axes - an Axes to plot against. One will be created if not included - legend: Boolean - Decision to generate a legend - - Returns - ------- - None - - Example - ------- - cpu.plot() - >>> - """ - - import matplotlib.pyplot as plt - from matplotlib.dates import ( - DayLocator, - HourLocator, - MonthLocator, - YearLocator, - MinuteLocator, - DateFormatter, - ) - - date_index = self.time.dt - if ax is None: - fig = plt.figure(1) - fig.autofmt_xdate() - ax = fig.add_subplot(111) - - window = (date_index[-1] - date_index[0]).astype(int) - - xlabel = "" - if window <= 3600: - minor_locator = MinuteLocator() - minor_formatter = DateFormatter("%M") - major_locator = HourLocator() - major_formatter = DateFormatter("\n%Y-%m-%d %H:%M") - xlabel = "Minute" - elif window <= 86400: - minor_locator = HourLocator() - minor_formatter = DateFormatter("%H:%M") - major_locator = DayLocator() - major_formatter = DateFormatter("\n%Y-%m-%d") - xlabel = "Hour" - elif window <= (7 * 86400): - minor_locator = HourLocator(interval=6) - minor_formatter = DateFormatter("%H:%M") - major_locator = DayLocator() - major_formatter = DateFormatter("\n%Y-%m-%d") - xlabel = "Hour" - elif window <= (60 * 86400): - interval = 1 - if len(date_index) > 30: - interval = 2 - minor_locator = DayLocator(interval=interval) - minor_formatter = DateFormatter("%m-%d") - major_locator = YearLocator() - major_formatter = DateFormatter("\n%Y") - xlabel = "Day" - else: - minor_locator = MonthLocator() - minor_formatter = DateFormatter("%B") - major_locator = YearLocator() - major_formatter = DateFormatter("\n%Y") - xlabel = "Month" - - ax.xaxis.set_minor_locator(minor_locator) - ax.xaxis.set_minor_formatter(minor_formatter) - ax.xaxis.set_major_locator(major_locator) - ax.xaxis.set_major_formatter(major_formatter) - ax.fmt_xdata = DateFormatter("%Y-%m-%d %H:%M:%S") - - ax.set_title(self._generate_title(), fontsize=18) - ax.set_xlabel = xlabel - # OPTION: plot each stream separate axs? - # OPTION: markers/events/annotations - ax.plot(date_index, self.data, **kwargs) - if legend: - labels = self._generate_labels() - ax.legend(title="Streams", labels=labels[:5]) def copy(self): """Override the copy method to include the labels