def showPlot(date, data, file_name):
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
import datetime
fig, ax = plt.subplots()
ax.xaxis.set_major_locator(mticker.MaxNLocator(5))
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
print(date)
# print(data)
# date = [datetime.datetime(1, 1, 1, 0, 0), datetime.datetime(1, 1, 2, 0, 0), datetime.datetime(1, 1, 3, 0, 0), datetime.datetime(1, 1, 4, 0, 0)]
# data = [1, 2, 3, 4]
ax.plot(date, data)
# fig.plot([1, 2, 3], [1, 1, 1])
fig.savefig(file_name)
plt.close(fig)
# def showPlotMix(data, file_name='test.png'):
# fig, arr = plt.subplots(nrows=len(data), sharex=True)
# print('showPlotMix')
# for i, d in enumerate(data):
# # print(len(d[0]))
# for j, td in enumerate(d[0]):
# # print(len(td))
# print(len(d[1][j]))
# arr[i].plot(d[1][j], td)
# fig.savefig(file_name)
# plt.close(fig)
评论列表
文章目录