diff --git a/plot_wf_longterm.py b/plot_wf_longterm.py index 0b5f22d..b07ca9d 100755 --- a/plot_wf_longterm.py +++ b/plot_wf_longterm.py @@ -161,21 +161,23 @@ 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: - ax.yaxis.set_minor_locator(HourLocator(interval=max(1, args.resolution // 100))) - ax.yaxis.set_minor_formatter(DateFormatter('%H')) + if args.resolution <= 600: + ax.yaxis.set_minor_locator(HourLocator(interval=max(1, args.resolution // 100))) + ax.yaxis.set_minor_formatter(DateFormatter('%H')) ax.xaxis.set_major_locator(MultipleLocator(1.0)) ax.set_xlabel('Frequenz [MHz]')