Visualization
The ausdex
module comes with several data visulizations built with plotly. Inflation data can be visulized by a time series of the values of a given price inflated to a particular “dollar year”. Additionally, the consumer price index (CPI) time series can be plotted. Visualizations can be created programmatically or via the command line and saved as images or HTML.
[1]:
# The following code is needed to render the plots in a way that can be displayed nicely in the documentation.
import plotly.io as pio
pio.renderers.default = 'notebook'
def show_fig_in_docs(fig):
""" Shows plotly figures in a wa display in the documentation. """
fig.update_layout(width=650, paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
fig.show()
Change in Consumer Price Index (CPI)
Produces a plot of the percentage change from corresponding quarter of previous year
ausdex plot-cpi-change [OPTIONS]
With the following options:
--show
/--no-show
Whether or not to show the figure in a browser. [default: show]--output
The path to where the figure will be saved. Output can be PDF, JPG, PNG or HTML based on the extension.--help
Show the help message.
The same plot can be made programmatically via the API. More information found in the API docs. See the following example:
[2]:
from ausdex.viz import plot_cpi_change
fig = plot_cpi_change()
show_fig_in_docs(fig)
Downloading https://www.abs.gov.au/statistics/economy/price-indexes-and-inflation/consumer-price-index-australia/jun-2022/640101.xlsx to /Users/rturnbull/Library/Caches/ausdex/640101-jun-2022.xlsx
Consumer Price Index (CPI) over time
A time series fo the CPI can be generated via the following command:
ausdex plot-cpi [OPTIONS]
With the following options:
--show
/--no-show
Whether or not to show the figure in a browser. [default: show]--output
The path to where the figure will be saved. Output can be PDF, JPG, PNG or HTML based on the extension.--start-date
Date to set the beginning of the time series graph. Defaults to None, which starts in 1948.--end-date
Date to set the end of the time series graph too. If empty, then the end date to the most recent quarter.--location
The location for calculating the CPI. Must be one of: Australia, Sydney, Melbourne, Brisbane, Adelaide, Perth, Hobart, Darwin, Canberra. Default: Australia.--title
A custom title of the plot.--help
Show the help message.
The same plot can be made programmatically via the API. More information found in the API docs. See the following example:
[3]:
from ausdex.viz import plot_cpi_timeseries
fig = plot_cpi_timeseries(start_date=1960, end_date='12-12-2016')
show_fig_in_docs(fig)
Equivalent dollar value over time
An inflation chart can be created via the following command:
ausdex plot-inflation [OPTIONS] COMPARE_DATE
With the following arguments and options:
COMPARE_DATE
: Date to set relative value of the dollars too.
Options:
--show
/--no-show
Whether or not to show the figure in a browser. [default: show]--output
: The path to where the figure will be saved. Output can be PDF, JPG, PNG or HTML based on the extension.--start-date
: Date to set the beginning of the time series graph. Defaults to None, which starts in 1948.--end-date
: Date to set the end of the time series graph too. If empty, then the end date to the most recent quarter.--location
The location for calculating the CPI. Must be one of: Australia, Sydney, Melbourne, Brisbane, Adelaide, Perth, Hobart, Darwin, Canberra. Default: Australia.--value
: Value you incompare_date
dollars to plot on the time series. Defaults to 1.--help
: Shows the help
The same chart can be created with the same arguments programmatically. More information found in the API docs. See the following example:
[4]:
from ausdex.viz import plot_inflation_timeseries
fig = plot_inflation_timeseries('12-12-2019', start_date='12-12-1950', end_date='12-06-2020')
show_fig_in_docs(fig)
[ ]: