Let's Draw a Progressbar with LaTeX4 years ago · February 2, 2018 · 9:52 pm
Today we gonna take a quick look at how we can leverage the strengths of custom command definitions (CCDs) in LaTeX to our advantage, and create easy and fast-to-use progressbar visualizations.
So when would you benefit from such visualizations? What's the use-case? In the context of my master thesis I have conducted a qualitative user study to evaluate my model transformation editor QViT which, besides personal interviews, also included the usage of questionnaires. Btw in my thesis' case the term product study would probably be of proper usage, since the aim was to evaluate a theoretical concept, rather than the humans using it. Anyway, for a condensed way of reporting the averaged results of that questionnaires, I decided to use progressbars in my thesis, as being illustrated in the following figure.
This choice of mine applies well, since we are dealing with so called "closed" questions, meaning that the answers to them are of binary nature. However, such progressbar-like visualizations are not limited by the number of parameters. It is also conceivable to include three or more different colored ranges, although in that case, I consider pie-charts to be the better choice, due to their power of putting relative differences in perspective.
Okay, enough reasoning for now. Let's dive into the actual code. My approach to designing custom functions, methods and procedures is always to start off with defining the interface of how I want to be able myself to invoke it in subsequent sections of the code. In other words, I scope and balance the level of parameterization that is appropriate in the specific situation with this technique. Another way of approaching what this technique tries to help with is to quite boldly consider the function to be nothing more than a tool, and to directly ask it what it can do for you. In my case of progressbars, I want it to be able to take a percentage and a color as input. That way, I have minimized the amount of parameters needed to provide for the command invocation, and thus have established a high degree of efficiency to its usage.
Note that I have out-sourced parameters like the width and height of the whole progressbar to constants for consistency reasons.
Now, it's a piece of cake to add a bit more readability to our otherwise dry-to-consume, purely numeric percentage values.
Please feel free to play around with the code and tell me about what you were able to achieve with or learn from it.