In-class programming—Altair
Due 2023-09-26, 11:59pm EST 3pts 40minPlease ask any questions about this assignment in class, or later today on Slack.
You are welcome to work with other students on this assignment.
Table of contents
- Change log
- Aim of the assignment
- Instructions
- Submission instructions
- Grading
- Tips, tricks, and troubleshooting
Change log
- N/A.
Aim of the assignment
Altair is a declarative statistical visualization library for Python, based on Vega and Vega-Lite. In this tutorial you will learn how to use Jupyter Lab and Altair.
Instructions
If you run into problems see the tips, tricks, and troubleshooting section below.
Setup instructions
-
Install Inkscape from https://inkscape.org/
-
Accept the GitHub Classroom assignment invitation by clicking this link to get your repository:
https://classroom.github.com/a/4qWn2rqn
For reference, this is the template repository your repository is being created from: https://github.com/NEU-DS-4200-F23/In-Class_Programming--Altair.
Recall our general instructions and policies on GitHub Classroom assignments.
-
Clone your GitHub-Classroom-generated repository to your local machine.
E.g., in your terminal / command prompt
CD
to where you want the folder for this activity to be. Then run:git clone <YOUR_REPO_URL>
CD
or open a terminal / command prompt window into the cloned folder.-
Create and activate a virtual environment for this project. You may need to modify the code you use depending on what Python you have installed and how your machine is configured. To do so, run the setup commands below.
-
On macOS or Linux, run these three commands separately in case there are errors:
python3 -m venv env
source env/bin/activate
which python
-
On Windows, run these three commands separately in case there are errors:
python -m venv env
.\env\Scripts\activate.bat
where.exe python
Check the path(s) provided by
which python
orwhere.exe python
—the first one listed should be inside theenv
folder you just created. -
-
Install necessary packages.
python -m pip install -r requirements.txt
This may take a few minutes.
Run Jupyter Lab and create a notebook
- Run
python -m jupyter lab
. It should open Jupyter Lab in your default browser. - Create a new Jupyter Notebook named
south_end.ipynb
. - Follow along with the in-class tutorial. Once you have written code in a cell you can run it with
ctrl+enter
. In the menu you can run all cells and restart the kernel to clear variables. If you get lost, you can look atsouth_end_complete.ipynb
. - You will need to also do the infographic creation in Inkscape or Adobe Illustrator. Save your infographic as
infographic.svg
.
When we are done with the tutorial, if you have time…
- Start working through the Altair data visualization curriculum.
At the end of the exercise…
Optionally clear your output
- I used to warn folks to clear the outputs of all cells before commiting .ipynb files. This decreases file size, removes unnecessary metadata, and makes diffs easier to understand. In Jupyter Lab you can use the GUI: Edit->Clear All Outputs. But here, we’re using the
jupytext
package to automatically create a twin.py
file you can run using normal Python! It is much easier to diff.
Quit Jupyter Lab and the virtual environment
- Make sure to save your .ipynb file and shutdown Jupyter Lab properly through the file menu. Otherwise, you need to use
jupyter notebook stop
. - Deactivate the venv to return to your terminal using
deactivate
.
Commit and push your code (but first…)
-
Only if you have made any changes to the required packages (you probably didn’t), first export a list of all installed packages and their versions:
pip freeze > requirements.txt
-
Make sure to add all your required files, including the
.ipynb
file and any images to the git repo. -
Finally, commit all your local files and push them to the remote repository on GitHub.
Submission instructions
-
Ensure that:
- You cleared all cell outputs.
- All of your required files including
south_end.ipynb
andinfographic.svg
are committed and pushed to the remote repository on GitHub which was generated by GitHub Classroom. We will grade based on what is available in that repository.
Grading
This is a satisfactory grading assignment. If you followed the instructions you receive full marks and if not you receive a 0. Your submission is satisfactory if you completed the main goal part of the activity, including uploading infographic.svg
to your repo.
Criteria | Points |
---|---|
Satisfactory? | 3 |
Tips, tricks, and troubleshooting
If you run into trouble, first look at our relevant tutorials which have tips & tricks: