From 1a6b736ccaa3d8adcbca45a16f25b8cc29777803 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Thu, 16 Mar 2017 16:25:07 +0200 Subject: [PATCH] No longer use %-d for strftime since it is not supported in Windows --- python/fbprophet/forecaster.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 87788c4..18c79ce 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -15,7 +15,8 @@ from datetime import timedelta import pickle from matplotlib import pyplot as plt -from matplotlib.dates import DateFormatter, MonthLocator +from matplotlib.dates import DateFormatter, MonthLocator, num2date +from matplotlib.ticker import FuncFormatter import numpy as np import pandas as pd @@ -818,7 +819,8 @@ class Prophet(object): df_s['yearly_upper'], color='#0072B2', alpha=0.2)] ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2) months = MonthLocator(range(1, 13), bymonthday=1, interval=2) - ax.xaxis.set_major_formatter(DateFormatter('%B %-d')) + ax.xaxis.set_major_formatter(FuncFormatter( + lambda x, pos=None: '{dt:%B} {dt.day}'.format(dt=num2date(x)))) ax.xaxis.set_major_locator(months) ax.set_xlabel('Day of year') ax.set_ylabel('yearly')