File:Consumer Price Index Canada, All-Item Basket.svg
Summary
| Description |
English: Source: Statistics Canada. Table 18-10-0005-01 Consumer Price Index, annual average, not seasonally adjusted, accessed April 28, 2022 |
| Date | |
| Source | Own work |
| Author | WIlliam Chen |
| SVG development | |
| Source code | Python code#!/usr/bin/env python
# Author: William Chen. 2022-04-28
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
import numpy as np
# Import CPI, All-Items from 1914-2021
# Source:
year = [
1914,
1915,
1916,
1917,
1918,
1919,
1920,
1921,
1922,
1923,
1924,
1925,
1926,
1927,
1928,
1929,
1930,
1931,
1932,
1933,
1934,
1935,
1936,
1937,
1938,
1939,
1940,
1941,
1942,
1943,
1944,
1945,
1946,
1947,
1948,
1949,
1950,
1951,
1952,
1953,
1954,
1955,
1956,
1957,
1958,
1959,
1960,
1961,
1962,
1963,
1964,
1965,
1966,
1967,
1968,
1969,
1970,
1971,
1972,
1973,
1974,
1975,
1976,
1977,
1978,
1979,
1980,
1981,
1982,
1983,
1984,
1985,
1986,
1987,
1988,
1989,
1990,
1991,
1992,
1993,
1994,
1995,
1996,
1997,
1998,
1999,
2000,
2001,
2002,
2003,
2004,
2005,
2006,
2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014,
2015,
2016,
2017,
2018,
2019,
2020,
2021,
]
cpi = [
6,
6.1,
6.7,
7.9,
8.9,
9.8,
11.4,
10,
9.2,
9.2,
9,
9.1,
9.2,
9.1,
9.1,
9.2,
9.1,
8.2,
7.5,
7.1,
7.2,
7.3,
7.4,
7.7,
7.7,
7.7,
8,
8.5,
8.8,
9,
9.1,
9.2,
9.4,
10.3,
11.8,
12.2,
12.5,
13.8,
14.2,
14,
14.1,
14.1,
14.3,
14.8,
15.2,
15.3,
15.5,
15.7,
15.9,
16.1,
16.4,
16.8,
17.5,
18.1,
18.8,
19.7,
20.3,
20.9,
21.9,
23.6,
26.2,
29,
31.1,
33.6,
36.6,
40,
44,
49.5,
54.9,
58.1,
60.6,
63,
65.6,
68.5,
71.2,
74.8,
78.4,
82.8,
84,
85.6,
85.7,
87.6,
88.9,
90.4,
91.3,
92.9,
95.4,
97.8,
100,
102.8,
104.7,
107,
109.1,
111.5,
114.1,
114.4,
116.5,
119.9,
121.7,
122.8,
125.2,
126.6,
128.4,
130.4,
133.4,
136,
137,
141.6,
]
np_original_cpi = np.array([year, cpi])
# Create a selection (1998-2021)
np_cpi = np.delete(np_original_cpi, np_original_cpi[0] < 1980, 1)
# Plot the selection
pyplot.title(f'''Consumer Price Index, Canada, All-Items\n ({int(np_cpi[0][0])} - {int(np_cpi[0][-1])})''')
pyplot.ylabel("CPI, All-Items")
pyplot.xlabel("Year")
pyplot.locator_params(axis="y", nbins=(np_cpi[1][-1]/10))
pyplot.plot(np_cpi[0],np_cpi[1])
# For shorter selections, preserving optionality to have year labels on x axis
# pyplot.xticks(np_cpi[0])
# Add Gridlines to y axis
pyplot.grid(axis = 'y')
pyplot.savefig('cpi_canada.svg')
pyplot.show()
|
}}
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0
Category:Charts showing data through 2021
Category:Consumer price index
Category:Created with Matplotlib code
Category:Economic charts of Canada
Category:Economic statistics for Canada
Category:English-language statistical charts
Category:Price (text)
Category:Self-published work
Category:Valid SVG created with Matplotlib code