First Step (for programmers)
Drawing a spectrum is trivial: you connect n points with n-1 straight lines. The headache comes when you want all the objects: spectra (1D-2D-3D), integrals, annotations, peak-picking, projections, insets, overlays, etc.. correctly aligned along the frequency axis, even at the highest scale. I can give you a simple recipe to avoid the fore-mentioned headache. Start writing your program with a single line like the following declaration:
void DrawSpectrum( Spectrum *theSpectrum, Layout *theLayout, Destination *theDestination );
The rest of your work remains divided in two parts, an internal part that draws spectra and integrals, and an external part that draws the scale and makes the rest of the program. The only connecting point between the parts will be the line above.
The parameters point to, respectivelly:
- Either the printer or a window (the document's or any other) or a pdf document.
- The ppm limits and the material limits of the plot (e.g.: mm on paper or pixels). Only the called routine will check the consistency of both sets of limits. It is acceptable that the spectrum is completely outside the given limits (it's not drawn in this case). Also into this record (object/structure): the plotting style, the ancillary elements, etc...
- The static characteristics of the spectrum (data points and how to interpret them). Processing has nothing to do with drawing. Color information is also included here, so when the spectrum makes a trip outside its window it can still be recognized by the color.
Example: you invoke the routine "DrawSpectrum" 3 times, passing the same layout and the same destination and a different spectrum each time; you get the latter ones overlaid, perfectly aligned, even if acquired at different magnetic fields. This is only possible you have chosen ppm as the frequency unit (not Hz, not points).
Fitting 1D and 2D spectra into the same conceptual model is possible, just use the 2D model. You are lost if you think at the data points as "points". Convince yourself that they are tiles, or squares into a chessboard (a huge chessboard with millions of squares).
Example: you want to draw a full 1D spectrum, known to go from 10 to 0 ppm and made by 1000 points. The first point owns a region spanning from 10 and 9.99 ppm and it's centered at 9.995. Even if the spectral width goes from 10 to 0 ppm, you'll draw the plot from 9.995 to 0.005 ppm. The coordinates you pass into the "Layout" will however be 10 and 0.
If you start writing a 1D program and than you want to extent to the second (or third) dimension, don't be mislead.
You may arrive at the same conclusion following a different logical path. If the spectral width is 10 ppm, the distance between contiguous points must be 10/1000 = 0.01 ppm. With that distance, you cannot simultaneously have a point at 10 and another at 0 ppm (in this case there would be 1001 points). You must, instead, center the points inside the spectral width. While the left and right limits depends on the TMS position, which can be redefined at any moment, their distance depends on the dwell time (fixed when acquisition is started) and zero-filling. And because it is exactly determined, it cannot be a matter of opinion.
When your first step is correct, the rest follows consequentially. To tell the whole truth, I don't connect n points with n-1 lines, but this is another story...