CS494/594 -- Lab 1: Jgraph
Not your normal Dr. Plank Lab
The point of this lab is for you to do something interesting with jgraph, that would likely
be very difficult to do with another graphing package. I will give you options below. However,
if you want to do your own thing, now is the time to do it.
Here are the requirements:
- It must be visually interesting.
- You have to write a program to generate the jgraph. It can read data from a file, or from
the command line, but it has to generate the jgraph, and it can't be trivial.
It can be a shell script, as long as it's not a trivial shell script.
- It shouldn't be one program that generates one graph. It should do different things depending
on the data it reads or the command line arguments.
- You must have the project vetted by me. In other words, send me an email with the idea,
perhaps with some mockups, and I'll either say, "go ahead" or "try something else."
What you hand in
Your lab should be a git repository that contains:
- The source of your program. No precompiled binaries.
- A makefile that not only compiles your program (if necessary), but also runs it to create
at least five interesting jgraph outputs, which should be either pdf or jpg.
You can assume that ps2pdf and convert are installed.
- A README that contains compilation instructions and describes your program, with examples
and pictures.
- If you're worried about whether or not the TA will be able to compile and run your program,
schedule a meeting.
The TA should be able pull, then make, and be looking at PDF or JPG files.
The link above contains examples of good student projects that have been done for this lab.
Examples of projects that you can do
The Happy QR Code
I haven't implemented this, but here's the idea. Download the QR generator from
https://github.com/nayuki/QR-Code-generator.
You can use this to generate QR codes into PPM files:
UNIX> echo "Jim Plank" | QR-Code-generator-master/cpp/make_qr_code | convert - junk.ppm
Here's a jpg of the QR code:
Now, write a program that reads the PPM file, and distills the QR code into a grid of squares.
You'll note that the QR code above is a 21x21 grid of black or white squares. You can figure out
how big the squares are by reading those boxes in the three corners. You don't need a
QR reader for this -- just read the PPM. Have your program
emit the jgraph for the squares. However, it should emit a "happy" QR code, where:
- Instead of being black, each colored square can be a different color. Specify how you
want the colors generated on stdin.
- You can substitute patterns using the pattern feature of jgraph. Specify the patterns
using stdin.
- You can substitute pictures for some or all
some of the squares (by, for example, turning the picture
into a square eps and then plotting the eps rather than the square). Your QR code should
still be readable, since QR codes have redundancy built in. "Dark" pictures may suffice for
the black squares.
Again, do the specification on stdin.
This should work efficiently, even with decently large messages in the QR codes, which make them
more complex, or large pictures that you should shrink so the eps is not bloated.
Spirograph
If you never played with a spirograph game when you were young, you missed out.
If you don't know what it is, check out its
wikipedia page in https://en.wikipedia.org/wiki/Spirograph.
Write a program
spiro, that takes the following command line arguments:
- The parameters of the inner ring (or outer ring if you want to use one) -- e.g. number of
teeth, radius.
- For each "drawing", read the parameters of the drawing on standard input. E.g.:
- Color
- Number of teeth of the wheel.
- Starting position on the inner wheel.
- Distance of the hole to the edge of the wheel.
It will then emit jgraph for the drawing -- you'll have to do this by generating lines in jgraph
that have points really close together, so that they can emulate curves.
How fun is that?
I have too much data to plot
I'll give you the data for graphs like:
http://web.eecs.utk.edu/~jplank/plank/classes/cs494/494/notes/Jgraph/2019-IJCNN.jpg
Basically, each data file is 24,000 lines of input where each of these is a data point
for one of 240 parameter settings. First you have to cull 10 of the parameter settings, because
they don't make sense, and then you have to organize the data for each parameter into a tukey
plot, then create the jgraph with the proper labeling.
Will this help me next week on DraftKings?
The PGA (professional golf) tour keeps track of four "Shots Gained" statistics:
- "Off-The-Tee" is a measure of how a golfer's score is better than the field due to his shots off the tee.
- "Approach-The-Green" is a measure of how a golfer's score is better than the field due to his long shots into the green.
- "Around the green" is a measure of how a golfer's score is better than the field due to his short shots near the green.
- "Putting" is a measure of how a golfer's score is better than the field due to his putts once
he is on the green.
The sum of these measures is their "Shots Gained: Total". For example, let's take a look
at the 2020 US open championship. What I have below is the each web page that has the stats
for the tournament, plus the stat for five golfers:
- The winner, Bryson DeChambeau, who hits his drives a mile.
- The runner up, Matthew Wolff, who also hits his drives a mile.
- Zach Johnson, who came in 8th and is well known for scoring well despite not driving
the ball well.
- Lee Westwood, who came it 8th despite being 100 years old.
- Siugo Imahira, who came in last of all players who played all four rounds.
The numbers shown are totals for the four rounds of the tournament.
There's a really nice graphic that you can build to display shots gained,
where you have four boxes for each golfer, which contains the positive and
negative stats, and with a black bar for the total. Here's the graphic
for those five golfers:
It's a great graphic, because you can easily see how Wolff and DeChambeau excelled in
Approach-the-green, while Zach Johnson had a monster tournament with his putter.
Your program should take some form of input files that has Shots-Gained statistics,
(ideally pulled off the web automatically), and then create this graphic as jgraph.
Again, this is ideal, but if you have more golfers than will fit on a page, have it
produce multiple pages. Of course, have it sort the golfers from best total to worst.