Digital humanities


Maintained by: David J. Birnbaum (djbpitt@gmail.com) [Creative Commons BY-NC-SA 3.0 Unported License] Last modified: 2021-12-27T22:03:54+0000


SVG assignment 2

The text

For this homework we will be working with a small list of Greek dramas, available at http://dh.obdurodon.org/greekDrama.xml. There is a <metaData> element at the top that carries the labels for the columns. The rest of the document consists of <play> elements, each of which lists the genre, author, title, year, id (an arbitrary number), and length (in words) of the play.

The SVG output

Your task is to write XSLT that will generate a graph to explore trends in word count over time. You should arrange the plays chronologically along the X axis and plot the word count on the Y axis. You should also attach a label to each point on the chart indicating the title and year of the play. Our initial output (see also the enhanced version below) looks like:

Oedipus at Colonus (401) Bacchae (405) Iphigenia in Aulis (405) Orestes (408) Electra (409) The Trachiniae (409) Philoctetes (409) Oedipus Rex (409) Phoenician Women (410) Helena (412) Electra (413) Iphigenia in Tauris (413) Trojan Women (415) Ion (417) The Suppliants (421) Heracles (422) Hecuba (425) Andromanche (427) Heracleidae (428) Hippolytus (428) Medea (431) Cyclops (438) Alcestis (438) Antigone (441) Ajax (451) Eumenides (458) Libation Bearers (458) Agamemnon (458) The Suppliants (463) The Seven Against Thebes (467) The Persians (472)

Our output consists of SVG <circle> and <text> elements. As with the stooge bar chart in class, we drew the image in the upper right quadrant my using negative y coordinates and then shifted everything down into the lower right quadrant with the @transform="translate(x,y)" attribute. To rotate the text we assigned an attribute transform="rotate(1 2 3)" to the <text> elements, where the first parameter in rotate() represents the number of degrees to rotate the text and the other two represent the X and Y coordinates around which to perform the rotation. Don’t type 1 2 3! Those are placeholders; you have to determine your own values based on how much you want to rotate the text and what you want to rotate it around. Experiment with different values to see the results. You can rotate anything, by the way, not just text; see, for example, http://www.svgbasics.com/rotate.html.

Feel free to tinker with the presentational details of your SVG as long as you are producing a comparable representation of the same information.

The XSLT

As with the stooge transformation we did in class, our XSLT consists of a single template rule for the document node, which contains a single <xsl:for-each> element that collects the plays for pull processing. We use <xsl:sort> to sort the set of plays by year, calculate the x and y coordinates, and draw a circle with a small radius at the appropriate position, along with the rotated title and year of the play.

For additional SVG practice

For additional SVG practice, you might want to draw the X and Y axes, label them (years on the x axis and word counts on the y), and perhaps draw faint horizontal lines at regular, periodic heights.

Addendum

Finding ourselves with time to kill, we enhanced the output in several ways. First, we added x and y axes, both with value labels, as well as horizontal grid lines. Note that the grid lines are gray, rather than black, which lets them fulfill their purpose (helping the user to identify the values of the dots) without being overly obtrusive. In our original image, above, we spaced the plays evenly along the X axis. This misrepresents the timeline because some plays were written in the same year and others are separated by a variable number of years, which means that in the first image, the horizontal spacing is not proportional to the chronological distribution of the plays. In the new image, below, we space the plays in a way that is proportional to the amount of time between the years when they were written. For example, the horizontal distance between Heracles (written in 422) and Hecuba (425), written three years apart from each other, is three times as large as the space between The suppliants (421) and Heracles (422), written one year apart from each other.

The change in graphing required, in turn, that we change the way we present the textual information about the play, since with multiple plays in the same year, the original display strategy would have produced overlapping (illegible) text. We opted to put the textual information in a tool tip instead of displaying it directly; if you mouse over one of the dots and hover there, the title, author, year, and word count will materialize. We also color-coded the dots: plays by Euripides are blue, those by Sophocles are red, and those by Aeschylus are green.

This solution is not ideal for at least three reasons: 1) the hover target is small and difficult to hit with the mouse cursor, 2) there is nothing analogous to mouseover or hover events on touch devices, and 3) tool tips fade on their own after a brief interval, which may require a user who hasn’t finished reading to mouse out and mouse in again. The graph could also be improved by generating the horizontal coordinates as percentages, rather than fixed values, which would enable the entire image to resize, rather than truncate, when the user resizes the browser window.

The new graph is:

3000 4000 5000 6000 7000 8000 9000 10000 11000 12000 Oedipus at Colonus (Sophocles, 401, 8702 words) 401 Bacchae (Euripides, 405, 7597 words) 405 Iphigenia in Aulis (Euripides, 405, 9430 words) 405 Orestes (Euripides, 408, 10030 words) 408 Electra (Sophocles, 409, 7363 words) 409 The Trachiniae (Sophocles, 409, 8830 words) 409 Philoctetes (Sophocles, 409, 9280 words) 409 Oedipus Rex (Sophocles, 409, 10385 words) 409 Phoenician Women (Euripides, 410, 9879 words) 410 Helena (Euripides, 412, 9927 words) 412 Electra (Euripides, 413, 7672 words) 413 Iphigenia in Tauris (Euripides, 413, 8396 words) 413 Trojan Women (Euripides, 415, 7077 words) 415 Ion (Euripides, 417, 9240 words) 417 The Suppliants (Euripides, 421, 5426 words) 421 Heracles (Euripides, 422, 7902 words) 422 Hecuba (Euripides, 425, 7279 words) 425 Andromanche (Euripides, 427, 7398 words) 427 Heracleidae (Euripides, 428, 6240 words) 428 Hippolytus (Euripides, 428, 8157 words) 428 Medea (Euripides, 431, 8032 words) 431 Cyclops (Euripides, 438, 4104 words) 438 Alcestis (Euripides, 438, 6603 words) 438 Antigone (Sophocles, 441, 7914 words) 441 Ajax (Sophocles, 451, 7177 words) 451 Eumenides (Aeschylus, 458, 5297 words) 458 Libation Bearers (Aeschylus, 458, 5447 words) 458 Agamemnon (Aeschylus, 458, 8187 words) 458 The Suppliants (Aeschylus, 463, 4939 words) 463 The Seven Against Thebes (Aeschylus, 467, 5115 words) 467 The Persians (Aeschylus, 472, 5189 words) 472

The new graph seems to suggest that there may be a modest trend over time in favor of shorter plays. If that’s the case, an additional enhancement to the chart might be a statistical analysis of the apparent relationship between year of composition and length, and, if appropriate, the plotting of a regression line.