diff --git a/power_plot.py b/power_plot.py index 0c042690b314798eba0956dd78b9dec5379032e2..02aa31dbf40f48b97d81ef9bd48208e7cf68af4d 100755 --- a/power_plot.py +++ b/power_plot.py @@ -14,8 +14,7 @@ import matplotlib import matplotlib.pyplot as plt from matplotlib.widgets import Button, CheckButtons from matplotlib.collections import LineCollection -from matplotlib.ticker import FuncFormatter -from matplotlib.dates import HourLocator, date2num, num2date, AutoDateLocator +from matplotlib.dates import date2num, num2date, AutoDateFormatter from matplotlib.figure import Figure from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QComboBox @@ -42,10 +41,13 @@ class PowerPlot: self.ax.set_xlabel("Time (UTC)") self.ax.set_ylabel(yname) self.ax.xaxis_date() + + formatter = AutoDateFormatter(self.ax.xaxis.get_major_locator()) + formatter.scaled[1 / (24 * 60)] = "%H:%M" + + self.ax.xaxis.set_major_formatter(formatter) + self.min, self.max = None, None - self.ax.xaxis.set_major_formatter( - FuncFormatter(lambda x, pos: f"{num2date(x):%H:%M}") - ) fig.suptitle(yname, fontsize=16) fig.tight_layout() (self.totalplot,) = self.ax.plot([], [], ".", color="blue")