The data in the Excel file shows the concentration of particulate matter air pollution (PM2.5) in cities around the world. Very few historical observations of PM2.5 exist before the year 2000 so instead we use data produced from a mix of computer model simulations and satellite observations.
- Visit https://www.anaconda.com/products/individual in your web browser.
- Download the Anaconda Python 3 installer for macOS. These instructions assume that you use the graphical installer .pkg file.
- Follow the Anaconda Python 3 installation instructions. Make sure that the install location is set to “Install only for me” so Anaconda will install its files locally, relative to your home directory. Installing the software for all users tends to create problems in the long run and should be avoided.
- Clone this repo:
git clone git@github.com:wood-chris/airstripes.git
cd
into the repo- check that the conda base environment is activated (does the prompt include
(base)
)? If not, runconda activate base
- Running the python code for the barchart should just work!
python bar_race_chart_with_plotly.py
This should open a graph in your web-browser (and generate a file called racechart.html
)
This graph is interactive - click the play button below the graph.
- Do you understand (at a high level, not necessarily every line) the code? Can you change the behaviour of the code by changing bits of it?
- Can you change what the graph looks like? All the possible arguments for a
plotly
bar chart are documented at https://plotly.com/python-api-reference/generated/plotly.express.bar.html - Could you think of a different way of visualising the data? You might get inspiration at https://plotly.com/python/ (clicking an image will show you the code used to generate that graph)
matplotlib
is another plotting library in python, but doesn't support animated graphs. It has some examples at https://matplotlib.org/stable/gallery/index- Can you create a graph using
matplotlib
instead ofplotly
?