Exemplo n.º 1
0
def datasci():
    cong_dict = [houseDictPerYear(y) for y in range(1990, 2018)]
    sen_dict = [senateDictPerYear(y) for y in range(1990, 2018)]
    house = Table().with_columns(
        "Year", np.arange(1990, 2018), "House Bi-Partisan",
        np.array([(x['100'] + x['95']) * 100 / x['total'] for x in cong_dict]),
        "House Non Partisan",
        np.array([x['nonpart'] * 100 / x['total'] for x in cong_dict]),
        "House Collaborative",
        np.array([x['together'] * 100 / x['total'] for x in cong_dict]))
    senate = Table().with_columns(
        "Year", np.arange(1990, 2018), "Senate Bi-Partisan",
        np.array([(x['100'] + x['95']) * 100 / x['total'] for x in sen_dict]),
        "Senate Non Partisan",
        np.array([x['nonpart'] * 100 / x['total'] for x in sen_dict]),
        "Senate Collaborative",
        np.array([x['together'] * 100 / x['total'] for x in sen_dict]))
    total = senate.join("Year", house)
    #print(total)
    #total.scatter("Year")
    plt.axis([1989, 2020, 0, 100])
    plt.plot(total.column("Year"),
             total.column("House Bi-Partisan"),
             'k',
             c='g',
             label="House Bi-Partisan")
    plt.plot(total.column("Year"),
             total.column("Senate Bi-Partisan"),
             'k',
             c='y',
             label="Senate Bi-Partisan")
    #     plt.plot(total.column("Year"), total.column("House Non Partisan"), '*', c='g', label="House Non Partisan")
    #     plt.plot(total.column("Year"), total.column("Senate Non Partisan"), '*', c='y', label="Senate Non Partisan")
    #     plt.plot(total.column("Year"), total.column("House Collaborative"), '.', c='g', label="House Collaboration")
    #     plt.plot(total.column("Year"), total.column("Senate Collaborative"), '.', c='y', label="Senate Collaboration")

    drawParties(plt, "both")
    #plt.legend(bbox_to_anchor=(0.5, -0.15))
    plt.legend(loc=4)
    plt.ylabel("Percentage of Total Votes")
    plt.xlabel("Years (1990-2017)")
    plt.savefig("data.png", dpi=400)
    plt.show()
Exemplo n.º 2
0
 def join(self, *args, **kwargs):
     return self._fix_(Table.join(self, *args, **kwargs))