3

I'm trying to plot a data set that contains the results of some benchmarks across a number of tools on a set of input files. The problem is that there are more than 3000 test cases and I need to represent them all in a compact way (no more than a half page).

For this goal I'm trying to reproduce what I think is a sort of scatter plot from Shuppan and Darmawan 2011, "Evaluating LTL Satisfiability Solvers":

Example plot

On the x axis there are the input files divided by category, sorted by size, and the y axis reports the different tools that have been benchmarked. The color reports the time taken by the given tool to solve the given input, darker is slower (and black is timed out). Note that on che x axis are reported more than 3000 input tests. The names you see are only the categories where these tests are divided. So each single colored bar is a particular input for a particular tool (bars could have been points as well, I suppose they choose bars for readability since they needed vertical space to write the tools names anyway).

I have a tab-separated file which lists a test file for each row, with the benchmark data of each tool as columns. Input files are already divided by category in the rows. In other words, the CSV rows are something like this:

category filename size time_tool_1 time_tool_2 time_tool_3 ... time_tool_N

Rows are already grouped by category and sorted by size inside a single category.

I'm looking at the best way to reproduce this kind of plot in LaTeX. For what I can tell, this is a sort of scatter plot, albeit a strange one. I've used pgfplots before but never to do scatter plots. I'm also considering the idea of manually drawing it with tikz, reading data using pgfplotstable. I've never used gnuplot nor R, so I'd rather stay inside the LaTeX world, but I'm open to suggestions.

So the question is twofold (and a half):

  • How would you approach the drawing of a plot like this?
  • Which packages and tools are better suited?
  • By the way, are there better ways to plot and represent the same data? Consider that, in contrast to the referenced paper, I'm not doing a general survey benchmark of all the tools, but I'm comparing a specific tool against all the others, so maybe there is an even more compact or more readable or easier way to represent the same thing.
  • What do the mini-colored bars represent? For example, what's the difference between, let's say, 3 yellow, 2 orange, 4 black and 5 yellow, 4 black? And why some columns are larger, i.e. contain more minibars, than the others? – Alenanno Jan 21 '16 at 16:28
  • There are circa 3000 test files in this plot. Each bar is one of them. The names on the axis are the names of the categories in which test files are divided. Single test files are ordered by size inside the same category. So in a single "block" you see all the formulae of the same kind in order of size for a given tool. Color is the time taken by that tool on the single test file. Maybe I should edit the question to better explain this point? – gigabytes Jan 21 '16 at 17:48
  • Well, the more context the better, because the how depends on what it's going to be. – Alenanno Jan 21 '16 at 17:50
  • 1
    I would go about it by putting many axis environments side by side or with groupplots library (without ticks) – percusse Jan 22 '16 at 10:45
  • 1
    @EnricoMariaDeAngelis We already have ybar plots doing that. As long as you don't run out of PDF objects on the page it's OK. – percusse Jan 22 '16 at 10:54
2

I guess it is not necessary to use PGFPLOTS whenever there are data to plot.

My approach is divided into two parts. First, I use PGFPLOTSTABLE to read the table. This package is good at reading tables. It should be able to read your CSV file.

Second is about how to draw. In comments (and in general) we would suggest PGFPLOTS because it has built-in "templates" and mathematics/statistics engine. But in this case, you have a pretty clear idea about what the output should be like. So I simply built a double-loop that draws what you want in a tikzpicture.

\documentclass[border=9,tikz]{standalone}
\usepackage{pgfplotstable}
\begin{document}

\pgfplotstableread{
    category                filename   size    a  b  c  d
    rozier-counter          file_01    size_01 10 12 21 88
    rozier-counter          file_02    size_02 20 24 34 99
    rozier-counter          file_03    size_03 30 48 55  x
    rozier-counter          file_04    size_04 40 96 89  x
    rozier-counter-carry    file_11    size_11 35  4  x  5
    rozier-counter-carry    file_12    size_12 45 16  x  7
    rozier-counter-carry    file_13    size_13 55 36  x  5
    rozier-counter-carry    file_14    size_14 65 64  x  8
    rozier-pattern-Eformula file_21    size_21  1 10 28  2
    rozier-pattern-Eformula file_22    size_22  8  x 57  7
    rozier-pattern-Eformula file_23    size_23 27  x 87 22
    rozier-pattern-Eformula file_24    size_24 64  x  x 67
    rozier-pattern-Sformula file_31    size_31 20  7 12 11
    rozier-pattern-Sformula file_32    size_32  x 19 34 23
    rozier-pattern-Sformula file_33    size_33 16 37 56 47
    rozier-pattern-Sformula file_34    size_34 26 53 78 95
}\data

\pgfplotstablegetrowsof\data\pgfmathsetmacro\rowcount{\pgfplotsretval-1}
\pgfplotstablegetcolsof\data\pgfmathsetmacro\colcount{\pgfplotsretval-1}
\def\lastrowcategory{not yet defined}
\def\categorycount{0}

\tikzset{
    map color/.code={
        \if x#1
            \tikzset{fill=black}
        \else
            \tikzset{fill=red!#1!yellow}
        \fi
    }
}

\tikz[x=10]{
    \foreach\i in{0,...,\rowcount}{
        \pgfplotstablegetelem{\i}{[index]0}\of\data
        \ifx\lastrowcategory\pgfplotsretval\else
            \xdef\lastrowcategory{\pgfplotsretval}
            \fill(\i+\categorycount/3,2)rectangle+(1/3,\colcount-.9)(\i+\categorycount/3,2.8)node[rotate=-60,above right]{\lastrowcategory};
            \pgfmathsetmacro\categorycount{\categorycount+1}\xdef\categorycount{\categorycount}
        \fi
        \foreach \j in{3,...,\colcount}{
            \pgfplotstablegetelem{\i}{[index]\j}\of\data
            \fill[map color=\pgfplotsretval](\i+\categorycount/3,\j)rectangle+(1,1);
        }
    }
    \fill(\rowcount+1+\categorycount/3,2)rectangle+(1/3,\colcount-.9);
}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.