# graph of Israel's population, by religion
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
# from: Israel Central Bureau of Statistics, https://www.cbs.gov.il/he/publications/doclib/2021/2.shnatonpopulation/st02_02.pdf
# format: [Year, Jewish Population, Muslim Population, Christian Population, Druze Population, Total Population]
data = np.array([
[1949, 1013.9, 111.5, 34, 14.5, 1173.9],
[1950, 1203, 116.1, 36, 15, 1370.1],
[1951, 1404.4, 118.9, 39, 15.5, 1577.8],
[1952, 1450.2, 122.8, 40.4, 16.1, 1629.5],
[1953, 1483.6, 127.5, 41.4, 16.8, 1669.4],
[1954, 1526, 131.8, 42, 18, 1717.8],
[1955, 1590.5, 136.2, 43.3, 19, 1789.1],
[1956, 1667.5, 141.3, 43.7, 19.8, 1872.4],
[1957, 1762.8, 146.8, 45.8, 20.5, 1976],
[1958, 1810.2, 152.8, 47.3, 21.4, 2031.7],
[1959, 1858.8, 159.2, 48.3, 22.3, 2088.7],
[1960, 1911.3, 166.3, 49.6, 23.3, 2150.4],
[1961, 1981.7, 174.9, 51.3, 26.3, 2234.2],
[1962, 2068.9, 183, 52.6, 27.3, 2331.8],
[1963, 2155.6, 192.2, 53.9, 28.5, 2430.1],
[1964, 2239.2, 202.3, 55.5, 28.6, 2525.6],
[1965, 2299.1, 212.4, 57.1, 29.8, 2598.4],
[1966, 2344.9, 223, 58.5, 31, 2657.4],
[1967, 2383.6, 289.6, 71, 32.1, 2776.3],
[1968, 2434.8, 300.8, 72.2, 33.3, 2841.1],
[1969, 2506.8, 314.5, 73.5, 34.6, 2929.5],
[1970, 2582, 328.6, 75.5, 35.9, 3022.1],
[1971, 2662, 344, 77.3, 37.3, 3120.7],
[1972, 2752.7, 360.6, 73.8, 37.8, 3225],
[1973, 2845, 377.2, 76.7, 39.3, 3338.2],
[1974, 2906.9, 395.2, 78.7, 40.8, 3421.6],
[1975, 2959.4, 411.4, 80.1, 42.2, 3493.2],
[1976, 3020.4, 429, 82, 43.9, 3575.4],
[1977, 3077.3, 446.5, 83.8, 45.6, 3653.2],
[1978, 3141.2, 463.5, 85.5, 47.3, 3737.6],
[1979, 3218.4, 481.2, 87.6, 49, 3836.2],
[1980, 3282.7, 498.3, 89.9, 50.7, 3921.7],
[1981, 3320.3, 513.7, 91.5, 52.3, 3977.7],
[1982, 3373.2, 530.8, 94, 65.6, 4063.6],
[1983, 3412.5, 542.2, 95.9, 68, 4118.6],
[1984, 3471.7, 559.7, 98.2, 70, 4199.7],
[1985, 3517.2, 577.6, 99.4, 72, 4266.2],
[1986, 3561.4, 595, 100.9, 74, 4331.3],
[1987, 3612.9, 614.5, 103, 76.1, 4406.5],
[1988, 3659, 634.6, 105, 78.1, 4476.8],
[1989, 3717.1, 655.2, 107, 80.3, 4559.6],
[1990, 3946.7, 677.7, 114.7, 82.6, 4821.7],
[1991, 4144.6, 701.4, 128, 84.8, 5058.8],
[1992, 4242.5, 725.4, 140.9, 87.1, 5195.9],
[1993, 4335.2, 751.4, 151.8, 89.3, 5327.6],
[1994, 4441.1, 781.5, 157.3, 91.7, 5471.5],
[1995, 4522.3, 811.2, 120.6, 92.2, 5612.3],
[1996, 4616.1, 839.9, 123.4, 94.5, 5757.9],
[1997, 4701.6, 867.9, 126.1, 96.7, 5900],
[1998, 4785.1, 899.8, 128.7, 99, 6041.4],
[1999, 4872.8, 934.1, 131.8, 101.2, 6209.1],
[2000, 4955.4, 970, 135.1, 103.8, 6369.3],
[2001, 5025, 1004.6, 138.5, 106.3, 6508.8],
[2002, 5094.2, 1038.3, 140.4, 108.5, 6631.1],
[2003, 5165.4, 1072.5, 142.4, 110.8, 6748.4],
[2004, 5237.6, 1107.4, 144.3, 113, 6869.5],
[2005, 5313.8, 1140.6, 146.4, 115.2, 6990.7],
[2006, 5393.4, 1173.1, 149.1, 117.5, 7116.7],
[2007, 5478.2, 1206.1, 151.6, 119.7, 7243.6],
[2008, 5608.9, 1254.1, 150.2, 123.2, 7419.1],
[2009, 5701.9, 1286.5, 151.9, 125.3, 7552],
[2010, 5802.4, 1320.5, 153.4, 127.5, 7695.1],
[2011, 5898.4, 1353.6, 155.8, 129.5, 7836.6],
[2012, 5999.6, 1387.5, 158.4, 131.5, 7984.5],
[2013, 6104.5, 1420.3, 160.9, 133.4, 8134.5],
[2014, 6219.2, 1453.8, 163.5, 135.4, 8296.9],
[2015, 6334.5, 1488, 165.9, 137.3, 8463.4],
[2016, 6446.1, 1524, 168.3, 139.3, 8628.6],
[2017, 6554.5, 1561.7, 171.9, 141.2, 8797.9],
[2018, 6664.4, 1598.4, 174.4, 143.2, 8967.6],
[2019, 6773.2, 1635.8, 177.2, 145.1, 9140.5],
[2020, 6873.9, 1671.3, 179.5, 146.8, 9289.8],
[2021, 6982.6, 1708.9, 183.2, 148.6, 9453.5],
[2022, 7101.4, 1747.3, 185.5, 150.2, 9662.0]
]).transpose()
# percentage calculation
other = data[5] - (data[1] + data[2] + data[3] + data[4])
val = np.row_stack((data[1], data[2], data[3], data[4], other)*(100 / data[5]))
# stylize plot
#plt.style.use('./presentation.mplstyle')
fig, ax = plt.subplots()
#colorblind not safe
ax.stackplot(data[0], val, colors = ('#65acef', '#71c837', '#f05844', '#ffd42a', '#d8d1cc'))
ax.set_yticks(range(0, 101, 10))
ax.set_yticks(range(0, 101), minor = True)
ax.set_xticks(range(1900, 3000), minor = True)
plt.xlim(1949, 2022)
plt.ylim(0, 100)
fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
ax.yaxis.set_major_formatter(xticks)
ax.grid(linestyle='dotted', c="black", alpha = 0.5)
ax.tick_params(top=True, right=True)
plt.savefig('population_of_israel_by_religion_no_text_alt.svg')