Thursday, February 15, 2007

It's (not) a dirty job, but somebody's gotta do it

You may wonder why a former researcher spends his time to decide if the integral labels should be written horizontally or vertically. It happens, you know, that it's better to spend an evening to make something stupid like this (but that will certainly be used) than to spend 20 years only to write hundreds of scientific articles with no practical consequence for the health of mankind. Obviously, the risk is part of the game and both activities are welcome.
A couple of posts ago we witnessed the superiority of vertical labels when the spectrum is very crowded. Horizontal labels have their own merit, too: they are more readable. Last night I have worked a little to improve them. Here was the starting point:

This solution is not acceptable. A first remedy is to displace the labels, using the same algorithm implemented by peak-picking and by the vertical labels. I have found a program on the net that does it, in this way:

I like the idea, but the implementation is perfectible. I can't tell where a label ends and where the next begins. It's also hard to relate the green intervals to the corresponding peaks: my eyes get soon tired of this exercise. I still prefer to split the integrals in two rows, because the brackets stand out better. My improvement has consisted in displacing the labels. They can automatically displace themselves with a trivial algorithm, as depicted here below:

While the algorithm in the middle picture is sophisticated and slow (every region is aware of every other region), in the example at the bottom every region ignores all other regions. I start drawing integrals from the right (in increasing ppm order). When drawing a new integral, I know if there is already a label on its right, but ignore if there will something on the left. Nothing prevents me to adopt the more sophisticated (global) approach. My priority is different, however: I want the displaced label to keep a minimal overlap with its bracket. In this way I can do without the oblique handles. I can still combine the global algorithm with the restrained displacement, but I am already glad with the small advantage that I have gained so far.
The picture shows it effectively: if the label "4.069" (the first to be drawn) knew what was to follow, it would have displaced itself more to the right and there would have been more white space between "27.64" and "21.17". This can only been done with the slower global algorithm.
In conclusion: most people have survived well, until today, with centered labels (top picture). Now their work will be easier with auto-displacing labels (bottom picture), even if the implementation I have chosen is sub-optimal. It hasn't been so far such a boring job, after all.

0 Comments:

Post a Comment

<< Home