From e571c6178e3bf44e8963189f5e2db8158b9d58b7 Mon Sep 17 00:00:00 2001 From: Felix Blanke Date: Sun, 27 Aug 2023 18:58:35 +0200 Subject: [PATCH] Center xtick labels --- wsgi.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wsgi.py b/wsgi.py index a70c4e5..6aec640 100644 --- a/wsgi.py +++ b/wsgi.py @@ -122,13 +122,18 @@ def plot( # plt.gcf().autofmt_xdate() - plt.gca().xaxis.set_major_locator(mdates.WeekdayLocator([mdates.TU])) + # use timezone offset to center tick labels + plt.gca().xaxis.set_major_locator( + mdates.WeekdayLocator([mdates.TU], tz="Etc/GMT+12") + ) plt.gca().xaxis.set_minor_locator(mdates.DayLocator()) plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%a %d.%m.")) - plt.grid(True, which="major", axis="both") + plt.grid(True, which="major", axis="y") plt.grid(True, which="minor", axis="x") + plt.gca().tick_params("x", length=0, which="major") + def val_to_perc(val): return 100 * val / total_target