Spectral visualization scriptHi JMP SEs -
In my prior life as a chemist, I worked with spectral data to follow reaction progress. In some cases, this was the only way to get insight into the reaction kinetics and mechanism.
We would often visualize these reactions stacked up along a z-axis, similar to these images:


These graphs are a Y by X plot of each spectrum stacked along a Z-axis that is usually time. I would consider this a "pseudo" z axis in that the spectra are really just offset from each other along the X and Y axis to create what looks like a z-axis.
These graphs are not straight-forward to create in JMP and the attached script is my first attempt at creating an interface to build these types of graphs. With this interface you can create some unique visulaizations.
There are many directions this can go and it is far from complete. I posted the script here to get some feedback from the SE group. I plan to continue working on this as time allows to build some additional functionality, but for now it is good enough to generate some cool graphs. If you have customers who are working with spectral data, they might find this helpful. If there is enough interest, I could finish it up and put it in the Community.
If you decide to try it out, keep a few things in mind:
- The visuals look best if you use baseline correction so that the y-values at the highest and lowest x values are similar
- The gradient coloring scheme sometimes causes errors if you have more than 100 spectra
- It is best to use the sliders to adjust the axis settings, but if you change the axes with the grab tool manually, click "Remember Graph Settings" so the axes don't snap back when you make other adjustments
- Data can be formatted in Stacked, Column Functions or Row Functions like FDE. The script uses the Column Function format and will automatically change the format to this from the other formats.
Here are a few images of different possibilities using the Olive Oil data set and an animated GIF to show how to use the interface. Thanks for taking a look!




Re: Spectral visualization scriptThis would be a great Add-In!
Re: Spectral visualization script@SamGardner Yes, this is a really nice visualization! I really like this view since you can get a gradient along the Y axis, which you can't do with the "slices" that I am making.
Navigating the variable assignments, ensuring numeric labels, and reformatting into stacked format can sometimes be tricky. Since this script handles different data formats, it might be nice to include a way to get to this graph from any standard spectral data format and put all the data reshaping in the background.
Re: Spectral visualization scriptCool idea and and visualization tool.
You could also visualize this with Surface Plot. Requires that the ID column be numeric.

Re: Spectral visualization script@Ben_Ingham
If you try and make adjustments when you have data points turned on, it sometimes slows down, but if you are looking at line or area graphs it is pretty fast.
The script pulls all the original data into matrices and builds a graph box directly from these. It does not update a data table, so I think this helps with the speed. Every time you make an adjustment, it just deletes the graph box and rebuilds it.
Re: Spectral visualization scriptHi @scott_allen ,
Just had a play around with this, really great and I got it to work on another sample data set from my SL HPLC work (attached) with varying wavelengths, I've got some LC-MS data too that'll have a look through. Just a few thoughts:
- If you have more than 100 spectra, it would be great to then have the option of choosing the range on the spectra
- It would be useful to filter out by the z-axis value as well (i.e. filtering out wavelengths with no interest, or mass values)
-Similarly, it would be useful to see the x-axis values represented on the graph and to be able to invert the x-axis (in the example below, you can see the front values 'block' the detail behind, as an additional option on top of transparency)

- I think it would be really useful to provide a heatmap alongside this to show the results as a 2D plane - this is often used in conjunction with the 3D plots. For example, the plot below would appear as so....


Cheers,
Ben
Re: Spectral visualization scriptThis is really useful @scott_allen, I used to use a lot of 3D peak plots during my time developing HPLC methods. How well does JMP handle the large amount of data from spectras? I know from the past when I tried to do heatmaps it struggled on a standard laptop
Cheers,
Ben