Eunoia library creates accurate set diagrams across popular languages

Eunoia: Area-Proportional Euler and Venn Diagrams in Rust, Julia, Python, R, and JavaScript

Mathematical Software

Summary

Visualizing overlapping groups can be tricky because their relationships don't always fit nice shapes perfectly. The authors developed Eunoia, a software library that draws diagrams where the size of each overlapping area matches the group's size as closely as possible. It uses smart math tricks and checks how well the drawing fits the real data. Eunoia works in many programming languages and even inside web browsers, making it easier for people to create clear visuals about how groups relate.

What this means in practice

  • For data visualization engineers: Generate precise area-based set diagrams that help users interpret complex overlapping data relationships visually in dashboards and reports.
  • For web developers: Embed interactive, optimized Euler and Venn diagrams in browser applications using the WebAssembly-powered Eunoia library without needing server-side processing.

Authors

Johan Larsson, Nicole M. Lee

Abstract

Area-proportional Euler diagrams visualize sets and their intersections through regions whose areas represent their sizes. Because many set specifications have no exact geometric representation, constructing these diagrams requires numerical optimization and diagnostics that quantify the remaining discrepancies. Eunoia is a Rust library for fitting area-proportional Euler diagrams and constructing canonical Venn diagrams. It supports circles, ellipses, squares, and rectangles, computes region areas analytically, and provides exact analytical gradients for several shape families. Its fitting pipeline combines multidimensional scaling initialization with local refinement, global optimization when needed, and seeded restarts. Fitted layouts include residuals and goodness-of-fit statistics that help users assess how faithfully a diagram represents the data. Shared plotting routines extract region polygons, place labels, and pack unit glyphs and member names within regions. The same core implementation powers packages for R, Python, Julia, and JavaScript, a C interface, and a web application that fits diagrams entirely in the browser through WebAssembly. By centralizing fitting, geometry, diagnostics, and annotation in an independent library, Eunoia provides consistent set visualization across programming languages and interactive applications.