Labeling matplotlib curves without a legend

When a chart has a few lines on it, the usual way to tell them apart is a legend: a small box off to the side that maps each color to a name. It works, but it makes the reader do extra work. Your eye lands on a line, jumps to the legend, finds the matching color, reads the name, then jumps back. For every line, every time.

Tufte‘s advice is to put the label on the data instead. Write each name right along the line it belongs to. No color key, no round trip.

I wanted to do that in matplotlib, and there was no simple built-in way to run text along a curved line, so I wrote a small library for it called curved-text.

It draws a string along any (x, y) curve, one character at a time, with each character rotated to follow the local slope. You give it the curve, the text, and three placement controls:

  • pos: where along the curve the label sits, as a fraction from start (0) to end (1)
  • anchor: whether that point is the start, center, or end of the label.
  • offset: how far to lift the text off the line, perpendicular to it.

The layout is recomputed every time the figure draws, so the label stays glued to the curve when you resize the window or pan and zoom. It works on anything that draws on matplotlib, including seaborn and pandas plots.

pip install curved-text

The code is on GitHub with a gallery of examples, and it is MIT licensed. If you find it useful, or it breaks on something, let me know.

Free Contrast-to-Noise Ratio Estimator Tool

I am happy to announce this web application, designed to assist researchers working in pump-probe and time-resolved photoluminescence microscopy. This tool aims to make estimating the Contrast-to-Noise Ratio (CNR) for noisy 1-dimensional Gaussian profiles as simple and efficient as possible. It’s completely free to use.

Continue reading “Free Contrast-to-Noise Ratio Estimator Tool”

Is There Any Escape From Noise?

I’m thrilled to share that my inaugural first-author paper, “Quantifying Noise Effects in Optical Measures of Excited State Transport,” has been published in The Journal of Chemical Physics and has been selected as an Editor’s Pick! [A free-to-read preprint is available here.] This paper marks a significant milestone in my academic journey, and I couldn’t be more grateful to my research advisor, Erik M. Grumstrup, as well as my labmates and spouse for their kind and generous support.

Continue reading “Is There Any Escape From Noise?”

Against Parkinson’s Law: Reimagining Efficiency for Greater Innovation and Happiness

In modern corporate management, a controversial idea has reemerged, Parkinson’s Law. Proponents argue that the Law suggests that as organizations grow, individual workers tend to fill their days with less critical tasks or “busy work,” providing a rationale for tech companies to lay off significant portions of their engineering staff. They posit that by doing so, these firms will reap substantial gains in efficiency. However, this fascinating perspective contradicts my philosophical convictions about human creativity, innovation, and well-being.

Continue reading “Against Parkinson’s Law: Reimagining Efficiency for Greater Innovation and Happiness”

The etymology and meaning of methyl, ethyl, propyl, butyl

Chemistry study often feels like learning a new language due to its extensive vocabulary. Understanding word origins can greatly improve memory retention. Early chemistry nomenclature includes memorizing roots like methyl, ethyl, propyl, and butyl, representing 1 to 4 carbon chains in functional groups. This article offers a thorough explanation for those studying or interested in the origins of these roots. For more information, including an explanation of the diagrams, see Structure of Organic Molecules.

Continue reading “The etymology and meaning of methyl, ethyl, propyl, butyl”

Penrose Tessellation Cookie Cutters

Over the holiday break, I took a little time for a side quest that engaged my creativity while involving mathematics, 3D modeling, and baking. I designed a pattern based on Penrose tiles and made it into cookies.

Continue reading “Penrose Tessellation Cookie Cutters”

Lunar Eclipse 2022

This photograph is a time-lapse of the total lunar eclipse on May 15, 2022, taken in the Paradise Valley of the Yellowstone River in southwestern Montana just north of Yellowstone National Park. The moon rises in near-totality in the East, ascending like a firework above the Absaroka Range. 

Continue reading “Lunar Eclipse 2022”

No Borders on Stolen Lands International Juried Exhibition

I just received news that my latest work of digital art entitled “No Borders on Stolen Stars” has been accepted into the No Borders on Stolen Land International Juried Art Exhibition.

Continue reading “No Borders on Stolen Lands International Juried Exhibition”