# -*- coding:utf-8 -*-
import matplotlib.pyplot as plt
import matplotlib.dates as dt
from datetime import datetime
......
x = [datetime.strptime(d,'%Y%m%d').date() for d in cgdates]
ax = plt.gca()
af = plt.gcf()
#fig = plt.figure()
#ax = fig.add_subplot(2.2.1)
ax.set_title('Nokia CG Licenses usage')
ax.set_ylabel('licenses'.encode('utf-8'))
weekdays = dt.WeekdayLocator(dt.MONDAY)
alldays = dt.DayLocator()
ax.xaxis.set_major_locator(weekdays)
ax.xaxis.set_minor_locator(alldays)
weekdayFormatter = dt.DateFormatter('%d-%m-%Y')
ax.xaxis.set_major_formatter(weekdayFormatter)
plt.plot(x,cgaver,color='red',linewidth=2.5,linestyle='-',label='aver')
af.autofmt_xdate()
plt.legend(loc = 0,ncol = 2)
plt.show()
plt.savefig("licenses.jpg")
matplotlib坐标轴日期格式
最新推荐文章于 2023-05-30 15:26:48 发布