Homework 2: Plot Student Data
In this step, you will find a data set that you’re interested in, and then plot or visualize your data in a patch in any way that you like.
Implementation Steps
Plotting Your Data
Write a function called plotStudentData()
. It should be modeled after plotExampleData
, so we recommend debugging that function before you start this one.
You have a large degree of freedom in completing this part. The only constraints we're imposing are
- Your data set should have at least 50 values.
- Your data set should be saved in a plain-text file called
student_data.txt
, and committed to your repository. If you choose to use one of the provided data sets, just make a copy of it in yourembroidery/
directory calledstudent_data.txt
. - Your resulting visualization should fit in a patch that is no more than 50 × 50 units.
- You should have a satin-stitched edge around your patch. You can do a square or a rectangle, but you might also consider another shape (e.g., a circle).
- You should plot or in some other way visualize your data. You can do a line plot like we did for the previous part, but you might also consider an alternative way of visualizing the numbers in your own data set.
Beyond that, you are free to add any additional stitches you want. Can you make your plotted data part of a more elaborate picture for your patch?
Your visualization should generate a file called student_data.dst
,
which you will convert (with embconv
) to an image file called student_data.svg
for viewing.
Helpful Hints
Use Our Data, Or Choose Your Own!
We’ve provided some data sets in the /cs70/data/stats
directory. In each case, we have a .tsv
file that contains years and values, and a .txt
file that contains just the values. You can use any of these data sets if you like. (Just copy one of the .txt
files to your embroidery/
directory and rename it student_data.txt
.)
- S&P 500 Returns Data —
sp500.tsv
/sp500.txt
- Data from 1926-2024
- U.S. Unemployment Rate Data —
unemp.tsv
/unemp.txt
- Data from 1953-2023
- Life Expectancy Data
- Data from 1960-2023
lifeexp-usa.tsv
/lifeexp-usa.txt
data for the United Stateslifeexp-can.tsv
/lifeexp-can.txt
data for Canadalifeexp-gb.tsv
/lifeexp-gb.txt
data for the United Kingdom
- Data from 1960-2023
- Arctic Sea Ice Minimum Extent Data —
ice.tsv
/ice.txt
- Data from 1979-2024
- Sunspot Data (Yearly Mean) —
sunspot.tsv
/sunspot.txt
- Data from 1900-2024
- HMC Student Enrollment Data (FTEs) —
mudd-fte.tsv
/mudd-fte.txt
- Data from 1970-2024
If you want to find your own data set, some places to look include datahub, the World Bank, climate.gov, or NOAA. You shouldn’t feel limited to those, however—we’re excited to see what data you find and share!
What were those tips that were on the previous page? I think they still apply!
Don't Forget to Recompile (and Reconvert with embconv
!)
Remember that every time you change embroidery.cpp
, you need to recompile it, relink it, run ./maker
again and regenerate the .svg
file with embconv
before you can see the results. (If you fix a bug in the code and the output image doesn’t change, you probably forgot one of these steps.)
Pay Attention to Warnings (from clang++
and cpplint
)
We recommend that you fix compiler warnings immediately, rather than waiting until the end. Even if most warnings are about issues that don’t cause trouble in practice, sometimes warnings reflect very serious errors in your code!
Similarly, cpplint
is pretty picky about how you write your code, so your life will be better if you occasionally run it and correct the formatting as you go, rather than waiting until the end to fix dozens (or for larger programs, hundreds) of small annoying errors.
(When logged in, completion status appears here.)