tools.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:WaveletQuotes 作者: JobyKK 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号