Created
December 17, 2017 14:28
-
-
Save felipessalvatore/16c884c1e395db54922325b65995da07 to your computer and use it in GitHub Desktop.
Plotting a temporal series using matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from datetime import date | |
#data | |
logic_tuple = [(1936, 3), (1937, 6), (1938, 3), (1939, 5), | |
(1940, 2), (1941, 2), (1942, 7), (1943, 1), | |
(1944, 2), (1945, 2), (1947, 2), (1948, 4), | |
(1949, 7), (1950, 3), (1951, 2), (1952, 5), | |
(1953, 5), (1954, 7), (1955, 8), (1956, 7), | |
(1957, 12), (1958, 18), (1959, 29), (1960, 41), | |
(1961, 58), (1962, 72), (1963, 75), (1964, 69), | |
(1965, 75), (1966, 68), (1967, 77), (1968, 85), | |
(1969, 90), (1970, 96), (1971, 124), (1972, 175), | |
(1973, 162), (1974, 178), (1975, 190), (1976, 187), | |
(1977, 216), (1978, 192), (1979, 243), (1980, 211), | |
(1981, 232), (1982, 212), (1983, 332), (1984, 364), | |
(1985, 391), (1986, 530), (1987, 592), (1988, 716), | |
(1989, 746), (1990, 861), (1991, 1052), (1992, 1106), | |
(1993, 1222), (1994, 1361), (1995, 1228), (1996, 1306), | |
(1997, 1297), (1998, 1308), (1999, 1365), (2000, 1412), | |
(2001, 1403), (2002, 1473), (2003, 1576), (2004, 1781), | |
(2005, 2077), (2006, 2139), (2007, 2403), (2008, 2479), | |
(2009, 2457), (2010, 2497), (2011, 2673), (2012, 2827), | |
(2013, 2636), (2014, 2781), (2015, 2809), (2016, 2548), | |
(2017, 2100)] | |
ML_tuple = [(1936, 0), (1937, 0), (1938, 0), (1939, 0), | |
(1940, 0), (1941, 0), (1942, 0), (1943, 0), | |
(1944, 0), (1945, 0), (1947, 0), (1948, 0), | |
(1949, 0), (1950, 0), (1951, 0), (1952, 0), | |
(1953, 0), (1954, 0), (1955, 0), (1956, 0), | |
(1957, 0), (1958, 1), (1959, 4), (1960, 0), | |
(1961, 0), (1962, 2), (1963, 2), (1964, 1), | |
(1965, 0), (1966, 2), (1967, 1), (1968, 0), | |
(1969, 1), (1970, 0), (1971, 0), (1972, 0), | |
(1973, 2), (1974, 5), (1975, 5), (1976, 0), | |
(1977, 1), (1978, 0), (1979, 0), (1980, 0), | |
(1981, 3), (1982, 1), (1983, 2), (1984, 4), | |
(1985, 12), (1986, 30), (1987, 53), (1988, 45), | |
(1989, 61), (1990, 43), (1991, 64), (1992, 75), | |
(1993, 125), (1994, 120), (1995, 109), (1996, 109), | |
(1997, 131), (1998, 129), (1999, 112), (2000, 133), | |
(2001, 204), (2002, 244), (2003, 253), (2004, 321), | |
(2005, 350), (2006, 518), (2007, 459), (2008, 494), | |
(2009, 583), (2010, 1632), (2011, 770), (2012, 917), | |
(2013, 1058), (2014, 1254), (2015, 1534), (2016, 1975), | |
(2017, 2938)] | |
years = [date(y, 1, 1) for (y, p) in logic_tuple] | |
logic_papers = [p for (y, p) in logic_tuple] | |
ML_papers = [p for (y, p) in ML_tuple] | |
assert len(years) == len(logic_papers) == len(ML_papers) | |
# plotting | |
fig, ax = plt.subplots(1, 1, figsize=(12, 12)) | |
ax.grid(linewidth=0.4) | |
line1, = ax.plot_date(x=years, y=logic_papers, ls='-', label="papers on logic") | |
line2, = ax.plot_date(x=years, y=ML_papers, ls='-', label="papers on machine learning") | |
plt.legend(handles=[line1, line2], loc=2, fontsize=18) | |
fig.suptitle("Papers from 1936 to 2017", fontsize=24, fontweight='bold') | |
ax.set_xlabel("year", fontsize=20) | |
ax.set_ylabel('number of papers', fontsize=20) | |
name_path = "Logic_ML.png" | |
plt.savefig(name_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment