From 38481d4f0242dcd77685e6d1e82235d13232d99c Mon Sep 17 00:00:00 2001 From: Tammo Jan Dijkema <T.J.Dijkema@gmail.com> Date: Thu, 18 Jan 2024 09:46:21 +0100 Subject: [PATCH] Fix formatting --- power_plot.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/power_plot.py b/power_plot.py index 0c04269..02aa31d 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") -- GitLab