Mathematical Optimization for Data Visualization

In general, you could say data visualization is about maximizing information acquisition and minimizing confusion and effort. However, I do not know of any simple mathematical definition of the insights/ink ratio, so this page is limited to more concrete applications.

Applications

Graph layouts

The often used force-directed layouts combine an implicit objective function and a first order method to minimise it. Layered graph layouts use another objective function and other heuristics. Not only node positioning but also edge routing etc. can be subject to optimization.

Label positioning

Good label positions should be close to the labeled elements, while avoiding overlaps. This can be formulated and optimized mathematically. See, for instance Mathematically optimize label positions in scatter plots and (Making Line Plots Delightful with Optimized Direct Labeling. Going further, the choice of instances to label may also be an interesting problem.

Reordering/seriation

In categorical heatmaps, for instance, the rows and/or columns of may represent categorical variables whose order is not predetermined. In this case, applying a reordering or “seriation” algorithm can be very advantageous and reveal otherwise hidden structures.

Euler and bubble plots

In some cases, you need optimization to make a diagram useful at all, or even to understand if it is feasible. See From Circles to Stars: Euler Diagrams with Optimized Radially Convex Boundaries.

Color palette optimization

It is not only about moving things around. In some cases, picking the right colors can also be seen as an optimization problem.

Dimensionality reduction

If you want to visually make sense of high-dimensional data beyond a dozen dimensions, dimensionality reduction often becomes necessary. Interestingly, dimensionality reduction techniques are often based on mathematical optimization: PCA optimizes for maximal variance along each axis, and UMAP optimizes a low-dimensional embedding to preserve the neighborhood structure of the original data.

Methods

The first step is to formulate an optimization problem, defining variables and an objective function. The second step is to find values of the variables that optimize the value of the objective function. Mixed integer linear programming works nicely for some problems. Gradient descent and its variants also work nicely for some problems, when variables are mostly continuous and especially if you can formulate a reasonably smooth objective function. This is the approach I am following in vizopt, my Python package for mathematical optimization