From 9343e885e559e2408450f20a7153fc14b369bf2f Mon Sep 17 00:00:00 2001 From: David Llewellyn-Jones Date: Sat, 27 Aug 2022 00:32:54 +0300 Subject: [PATCH] Fix histocurve rendering The x axis used a range of numbers and dates: numbers of the points and dates for the axis range. This prevented the histocurve from being rendered. This changes the graph to use only numbers, but adds a formatter so that they're still shown as dates. This allows the graph to be rendered correctly again. --- graphs.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/graphs.py b/graphs.py index 50541ea..ac6327e 100755 --- a/graphs.py +++ b/graphs.py @@ -716,7 +716,12 @@ def create_stackedareacurve(self, width, dpi, filename): #ax[0].autoscale(enable=True, axis='x', tight=True) ax[0].set_ylim(bottom=0, top=ymax) #ax[0].set_xlim(left=dates[0], right=dates[len(dates) - 1]) - ax[0].set_xlim(self.start_date, self.end_date) + ax[0].set_xlim(self.start_date.toordinal(), self.end_date.toordinal()) + + # Display the x axis labels as dates rather than numbers + def formatter(x, pos): + return datetime.date.fromordinal(int(x)) + ax[0].xaxis.set_major_formatter(formatter) # Averages duration = self.dates[len(self.dates) - 1].toordinal() - self.dates[0].toordinal()