Better axis formatting for single-day plots

This commit is contained in:
Thomas Kolb 2023-07-02 17:06:14 +02:00
parent 01a4cb8feb
commit 4c333281cb

View file

@ -161,19 +161,21 @@ print("Formatting...")
ax.yaxis_date()
#ax.yaxis.set_major_locator(HourLocator(range(0, 25, 1)))
#ax.yaxis.set_minor_locator(MinuteLocator(range(0, 60, 20)))
#ax.yaxis.set_major_formatter(DateFormatter('%H:%M'))
#ax.yaxis.set_minor_formatter(DateFormatter('%M'))
if len(args.input) == 1:
# only one argument means that we plot at most 1 day. Use Hour and Minute
# locators for nicer formatting.
ax.yaxis.set_major_locator(HourLocator(range(0, 25, 1)))
ax.yaxis.set_minor_locator(MinuteLocator(range(0, 60, 20)))
ax.yaxis.set_major_formatter(DateFormatter('%H:%M'))
ax.yaxis.set_minor_formatter(DateFormatter('%M'))
else:
# we are plotting multiple files and therefore probably a long time. Use
# Day and Hour locators.
#loc = AutoDateLocator()
#ax.yaxis.set_major_locator(loc)
#ax.yaxis.set_major_formatter(DateFormatter('%Y-%m-%d %H:%M'))
ax.yaxis.set_major_locator(DayLocator(interval=max(1, args.resolution // 600)))
ax.yaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
ax.yaxis.set_major_locator(DayLocator(interval=max(1, args.resolution // 600)))
ax.yaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
if args.resolution <= 600:
if args.resolution <= 600:
ax.yaxis.set_minor_locator(HourLocator(interval=max(1, args.resolution // 100)))
ax.yaxis.set_minor_formatter(DateFormatter('%H'))