Author Archives: stern

tagging time series plots in Mathematica

I hate legends on time series graphs. It’s invariably a hassle trying to figure out which color or which little marker corresponds to which line, and the legend takes up space and distracts from the data. Far better to tag the end of each data series on the graph itself, as in this example:

This is actually easy to do in Mathematica, especially if you have a standard datatype, as we do, that includes the name of the data series in its header.

Similarly, it is sometimes better to forgo datapoints entirely and to simply graph using the explanatory text itself.

Here is the code that produced the latter graph:

masterdata = {{"short person", 1, 2}, {"taller person", 2,
3}, {"the tallest", 3, 4}};

graphingdata = Map[{#[[2]], #[[3]]} &, masterdata];

ListPlot[graphingdata, PlotRange -> {{1, 3.5}, {1.5, 4.5}},
PlotMarkers -> Null,
PlotLabel -> "Often it is nice to use text rather than dots",
Epilog ->
Map[(Text[
Style[#[[1]], FontFamily -> "Times New Roman",
FontSize -> 9], {#[[2]], #[[3]]}, {-1.2, 0}] &), masterdata]]

Edward Tufte would approve.