Commit 73d85e7d authored by Vincent Pelletier's avatar Vincent Pelletier

Use auto locator & formater.

With (hopefully) appropriate settings.
parent 75fdd631
...@@ -52,13 +52,7 @@ except ImportError: ...@@ -52,13 +52,7 @@ except ImportError:
else: else:
matplotlib.use('Agg') matplotlib.use('Agg')
import matplotlib.pyplot as pyplot import matplotlib.pyplot as pyplot
from matplotlib.dates import ( from matplotlib.dates import AutoDateLocator, AutoDateFormatter
DateFormatter,
DayLocator,
HourLocator,
AutoDateLocator,
AutoDateFormatter,
)
MONTH_VALUE_DICT = dict((y, x) for (x, y) in enumerate(('Jan', 'Feb', 'Mar', MONTH_VALUE_DICT = dict((y, x) for (x, y) in enumerate(('Jan', 'Feb', 'Mar',
...@@ -537,17 +531,14 @@ def main(): ...@@ -537,17 +531,14 @@ def main():
daily_data = data.getApdexData() daily_data = data.getApdexData()
date_list = [datetime.strptime(x[0], '%Y/%m/%d' + {'day': ' %H'}.get( date_list = [datetime.strptime(x[0], '%Y/%m/%d' + {'day': ' %H'}.get(
args.period, '')) for x in daily_data] args.period, '')) for x in daily_data]
date_range = date_list[-1] - date_list[0] date_locator = AutoDateLocator(minticks=3, maxticks=5)
if date_range < timedelta(2):
date_formatter = DateFormatter('%Y-%m-%dT%H')
date_locator = HourLocator(
interval=int((date_range / 4).total_seconds() / 3600))
elif date_range < timedelta(6):
date_formatter = DateFormatter('%Y-%m-%d')
date_locator = DayLocator()
else:
date_locator = AutoDateLocator()
date_formatter = AutoDateFormatter(date_locator) date_formatter = AutoDateFormatter(date_locator)
date_formatter.scaled = {
365.: '%Y',
30.: '%Y/%m',
1.: '%Y/%m/%d',
1. / 24: '%Y/%m/%d\n%H:%M',
}
apdex_plot = pyplot.subplot(2, 1, 1) apdex_plot = pyplot.subplot(2, 1, 1)
apdex_plot.xaxis.set_major_locator(date_locator) apdex_plot.xaxis.set_major_locator(date_locator)
apdex_plot.xaxis.set_major_formatter(date_formatter) apdex_plot.xaxis.set_major_formatter(date_formatter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment