Esempio n. 1
0
def main():
    month = input("please input month1 01 ~ 12:  ")

    l = []
    name_list_hc = []
    name_list_rb = []
    for (k, v) in config.YearToColor.items():
        a = "HC" + k + month
        b = "RB" + k + month
        l.append([a, b, a + " - " + b, v])
        name_list_hc.append(a)
        name_list_rb.append(b)

    datas_hc = contract_hc.load()
    datas_rb = contract_rb.load()

    m_hc = contract_hc.filter1(datas_hc, name_list_hc, False)
    m_rb = contract_rb.filter1(datas_rb, name_list_rb, False)

    ax = plt.gca()
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d'))
    ax.xaxis.set_major_locator(mdates.MonthLocator())

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

    diff_l = []
    for pair in l:
        diff_x = []
        diff_y = []
        if pair[0] not in m_hc or pair[1] not in m_rb:
            continue
        ma = m_hc[pair[0]]
        mb = m_rb[pair[1]]
        year = int("20" + pair[0][2:4])
        for (date, v) in ma.items():
            if date not in mb:
                continue
            diff_y.append(v - mb[date])
            diff_x.append(
                datetime.date(2019 + date.year - year, date.month, date.day))

        diff_l.append([pair[2], diff_x, diff_y, pair[3]])

    plt.xlabel(" price diff " + month)
    plt.ylabel("")
    ls = []
    labels = []
    for i, v in enumerate(diff_l):
        plt.plot(v[1],
                 v[2],
                 color=v[3],
                 linestyle='-',
                 linewidth=1,
                 label=v[0])
        labels.append(v[0])

    plt.legend(labels=labels, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()
Esempio n. 2
0
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()
Esempio n. 3
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()
Esempio n. 4
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()
Esempio n. 5
0
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()
Esempio n. 6
0
def main():
    month1 = ""
    month2 = ""
    if len(sys.argv) >= 3:
        month1 = sys.argv[1]
        month2 = sys.argv[2]
    else:
        month1 = input("please input month1 01 ~ 12:  ")
        month2 = input("please input month2 01 ~ 12:  ")

    l = []
    name_list = []
    for k, v in config.YearToColor.items():
        a = config.Name + k + month1
        b = config.Name + k + month2
        if month2 < month1:
            b = config.Name + config.NextYear(k) + month2
        l.append([a, b, a + " - " + b, v])
        name_list.append(a)
        name_list.append(b)

    datas = contract.load()
    m = contract.filter1(datas, name_list, False)

    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)

    diff_l = []
    for pair in l:
        diff_x = []
        diff_y = []
        if pair[0] not in m or pair[1] not in m:
            continue
        ma = m[pair[0]]
        mb = m[pair[1]]
        year = int("20" + pair[0][2:4])
        for (date, v) in ma.items():
            if date not in mb:
                continue
            diff_y.append(v - mb[date])
            diff_x.append(
                datetime.date(2019 + date.year - year, date.month, date.day))

        diff_l.append([pair[2], diff_x, diff_y, pair[3]])

    plt.xlabel("jd price diff " + month1 + " " + month2)
    plt.ylabel("")
    ls = []
    labels = []
    for i, v in enumerate(diff_l):
        plt.plot(v[1],
                 v[2],
                 color=v[3],
                 linestyle='-',
                 linewidth=1,
                 label=v[0])
        labels.append(v[0])

    plt.legend(labels=labels, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()
Esempio n. 7
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()
Esempio n. 8
0
import os
import sys
import csv
current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(current_dir + '/..')

import contract
import datetime
import config

cs = ["15", "16", "18"]
#cs.append("14")
#cs.append("17")
cs.append("19")

datas = contract.load()


def gen_diff(year, month1, month2):
    year = config.Name + year
    name_list = []
    a = year + month1
    b = year + month2
    name_list.append(a)
    name_list.append(b)

    m = contract.filter1(datas, name_list, False)

    diff_x = []
    diff_y = []
    if a not in m or b not in m:
Esempio n. 9
0
def main():
    month1 = input("please input month1 01 ~ 12:  ")
    month2 = input("please input month2 01 ~ 12:  ")

    cs = [["m11", "gold"], ["m12", "plum"], ["m13", "purple"], ["m14", "gray"],
          ["m15", "pink"], ["m16", "green"], ["m17", "brown"], ["m18", "blue"],
          ["m19", "red"], ["m20", "black"], ["m21", "yellow"]]

    l = []
    name_list = []
    for i, val in enumerate(cs):
        a = val[0] + month1
        b = val[0] + month2
        if month2 < month1:
            if i >= len(cs) - 1:
                continue
            b = cs[i + 1][0] + month2
        l.append([a, b, a + " - " + b])
        name_list.append(a)
        name_list.append(b)

    datas = contract.load()
    m = contract.filter1(datas, name_list, False)
    print(m)
    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)

    diff_l = []
    for pair in l:
        diff_x = []
        diff_y = []
        if pair[0] not in m or pair[1] not in m:
            print(pair)
            continue
        ma = m[pair[0]]
        mb = m[pair[1]]
        year = int("20" + pair[0][1:3])
        for (date, v) in ma.items():
            if date not in mb:
                continue
            diff_y.append(v - mb[date])
            diff_x.append(
                datetime.date(2019 + date.year - year, date.month, date.day))

        diff_l.append([pair[2], diff_x, diff_y])

    plt.xlabel("m price diff " + month1 + " " + month2)
    plt.ylabel("")
    ls = []
    labels = []
    for i, v in enumerate(diff_l):
        plt.plot(v[1],
                 v[2],
                 color=cs[i][1],
                 linestyle='-',
                 linewidth=1,
                 label=v[0])
        labels.append(v[0])

    plt.legend(labels=labels, loc='best', shadow=True)
    plt.grid(axis="y", linestyle="--")
    plt.show()