コード例 #1
0
ファイル: conbine_year.py プロジェクト: daniel-007/stock
def main():
    month = input("please input month 01 ~ 12:  ")
    cs = {}
    for (k, v) in config.YearToColor.items():
        cs[config.Name + k + month] = v

    datas = contract.load()
    m = contract.filter(datas, cs, True)
    plt.xlabel(config.Name + "xx" + month)
    plt.ylabel("")
    ls = []

    ax = plt.gca()
    #指定X轴的以日期格式(带小时)显示
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    #X轴的间隔为天
    ax.xaxis.set_major_locator(mdates.MonthLocator())

    y_major_locator = MultipleLocator(config.y_major_locator)
    ax.yaxis.set_major_locator(y_major_locator)

    for c in cs:
        if c not in m:
            continue
        d = m[c]
        ls.append(c)
        plt.plot(d["x"],
                 d["y"],
                 color=cs[c],
                 linestyle='-',
                 linewidth=1,
                 label=c)
    plt.legend(labels=ls, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()
コード例 #2
0
def main():
    year = input("please input year: ")

    cs = {}
    for (k, v) in config.MonthToColor.items():
        cs[config.Name + year + k] = v

    datas = contract.load()
    m = contract.filter(datas, cs, False)
    plt.figure(figsize=(20, 10))
    plt.xlabel("jd20" + year)
    plt.ylabel("")
    ls = []

    ax = plt.gca()
    #指定X轴的以日期格式(带小时)显示
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    #X轴的间隔为天
    ax.xaxis.set_major_locator(mdates.MonthLocator())

    y_major_locator = MultipleLocator(200)
    ax.yaxis.set_major_locator(y_major_locator)

    date_2_price = {}
    egg_price.load()
    for c in cs:
        if c not in m:
            continue
        d = m[c]
        ls.append(c)
        plt.plot(d["x"],
                 d["y"],
                 color=cs[c],
                 linestyle='-',
                 linewidth=1,
                 label=c)

        for i in d["x"]:
            if i in egg_price.date_2_price:
                date_2_price[i] = egg_price.date_2_price[i]
            else:
                print(i)

    dates = sorted(date_2_price)
    prices = []
    for k in dates:
        prices.append(date_2_price[k])
    ls.append("dayanglu egg price")
    plt.plot(dates,
             prices,
             color="black",
             linestyle='-',
             linewidth=1,
             label="大洋路价格")

    plt.legend(labels=ls, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()
コード例 #3
0
def main():
    month = input("please input month 01 ~ 12:  ")
    cs = {
        "sp14" + month: "gray",
        "sp15" + month: "pink",
        "sp16" + month: "green",
        "sp17" + month: "brown",
        "sp18" + month: "blue",
        "sp19" + month: "red",
        "sp20" + month: "black",
        "sp21" + month: "orange"
    }
    datas = contract.load()
    m = contract.filter(datas, cs, True)
    plt.xlabel("jdxx" + month)
    plt.ylabel("")
    ls = []

    ax = plt.gca()
    #指定X轴的以日期格式(带小时)显示
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    #X轴的间隔为天
    ax.xaxis.set_major_locator(mdates.MonthLocator())

    y_major_locator = MultipleLocator(200)
    ax.yaxis.set_major_locator(y_major_locator)

    for c in cs:
        if c not in m:
            continue
        d = m[c]
        ls.append(c)
        plt.plot(d["x"],
                 d["y"],
                 color=cs[c],
                 linestyle='-',
                 linewidth=1,
                 label=c)
    plt.legend(labels=ls, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()
コード例 #4
0
ファイル: gen_conbine_year.py プロジェクト: daniel-007/stock
def gen_pic(month):
    cs = {}
    for (k, v) in config.YearToColor.items():
        cs[config.Name + k + month] = v

    datas = contract.load()
    m = contract.filter(datas, cs, True)
    plt.figure(figsize=(20, 10))
    plt.xlabel("jdxx" + month)
    plt.ylabel("")
    ls = []

    ax = plt.gca()
    #指定X轴的以日期格式(带小时)显示
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    #X轴的间隔为天
    ax.xaxis.set_major_locator(mdates.MonthLocator())

    y_major_locator = MultipleLocator(100)
    ax.yaxis.set_major_locator(y_major_locator)

    for c in cs:
        if c not in m:
            continue
        d = m[c]
        ls.append(c)
        linewidth = 1
        if c[0:4] == "JD20":
            linewidth = 2
        plt.plot(d["x"],
                 d["y"],
                 color=cs[c],
                 linestyle='-',
                 linewidth=linewidth,
                 label=c)
    plt.legend(labels=ls, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.savefig("pictures/jdxx0x/" + month + ".png")
    plt.clf()
コード例 #5
0
def gen_pic(year):
    cs = {}
    for (k, v) in config.MonthToColor.items():
        cs[config.Name + year + k] = v

    datas = contract.load()
    m = contract.filter(datas, cs, False)
    plt.figure(figsize=(20, 10))
    plt.xlabel("jd20" + year)
    plt.ylabel("")
    ls = []

    plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True
    plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False

    ax = plt.gca()
    #指定X轴的以日期格式(带小时)显示
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    #X轴的间隔为天
    ax.xaxis.set_major_locator(mdates.MonthLocator())
    ax.yaxis.tick_left()

    y_major_locator = MultipleLocator(200)
    ax.yaxis.set_major_locator(y_major_locator)

    date_2_price = {}
    egg_price.load()
    for c in cs:
        if c not in m:
            continue
        d = m[c]
        ls.append(c)
        plt.plot(d["x"],
                 d["y"],
                 color=cs[c],
                 linestyle='-',
                 linewidth=1,
                 label=c)

        for i in d["x"]:
            if i in egg_price.date_2_price:
                date_2_price[i] = egg_price.date_2_price[i]
            else:
                print(i)

    dates = sorted(date_2_price)
    prices = []
    for k in dates:
        prices.append(date_2_price[k])
    ls.append("dayanglu egg price")
    plt.plot(dates,
             prices,
             color="black",
             linestyle='-',
             linewidth=2,
             label="大洋路价格")

    plt.legend(labels=ls, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.savefig("pictures/basis/" + year + ".png")
    plt.clf()