cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
ehchandlerjr
Level V

Graph Builder: How to make stacked plots with some displacement for each series

Hello - I have a spreadhseet in Excel that outputs a plot of multiple series all stacked and displaced from eachother, but also allows replicates to have a tighter spacing, as seen below:

ehchandler_0-1699455827524.png

However, this takes multiple sheets, and somewhat manual redoing of the displacement each time, as well as constantly adjusting the colors because that's hard to control in excel. JMP would be a thousand times easier.

 

Is there a way in graph builder (or, to avoid the XY problem, somewhere else in JMP) that will allow the ease of a drag and drop to acheive this? Even if there's manual tinkering with the spacing required, the drag bar thing in graph builder would make it so much easier. I don't seem to be able to recreate it, but maybe I'm just missing something, and thought I would ask.

 

Thanks!

Edward Hamer Chandler, Jr.
6 REPLIES 6
hogi
Level XI

Re: Graph Builder: How to make stacked plots with some displacement for each series

You could use a formula colum on the y axis where you add color colum × scalefactor to the original y values.
ehchandlerjr
Level V

Re: Graph Builder: How to make stacked plots with some displacement for each series

Oh interesting. Yea that would do it, though its less of a graph builder solution. I wonder if there's a way to dynamically pick the color series and the scalefactor based on the *series* variable that tells jmp what rows are in what series. Hmmmmmm. I'll have to think about that one.

Edward Hamer Chandler, Jr.
SDF1
Super User

Re: Graph Builder: How to make stacked plots with some displacement for each series

Hi @ehchandlerjr ,

 

  As far as I know, there is no dynamic way (i.e. using Graph Builder alone) to create offset spectra like you're after, other than manually creating new column formulas that take the column of interest and add a fixed offset. But, this is exactly what my script does in an automated way, which will save you considerable time. In fact, if you are going to be doing this a lot and repeatedly, I would look into scripting with JSL to do this in an automated way for you. You will save TONS of time over dynamic manipulation of the graph. Sometimes setting up an analysis or graph initially dynamically first is needed in order to learn how to script it, but then once you have it and can apply to it other data tables, it's so much faster to have JSL code do it for you. With scripting, you can go in and assign each spectrum a specific color, and you could do this based on the column number within the data table, for example:

 

  According to the JMP JSL Scripting Guide v16, pp. 660-662, the standard JMP color schemes are:

SDF1_0-1699537367670.png

  And then each of those colors can be subsequently altered by making them light, medium light, medium dark, and dark:

SDF1_1-1699537445591.png

 

Or, if you wanted to change the global color scheme, you could go under File > Preferences, select Graphs up top (on the left), then click on the color scheme called "Categorical", bottom right hand. 

SDF1_2-1699537908578.png

You then get a screen like this, and for example, if I choose the bottom Chromatic style and again plot the spectra, it looks like this (the order can also be reversed):

SDF1_3-1699537967058.png

SDF1_4-1699538016312.png

 

  The only drawback to that method is that this is now the global color scheme for all graphs within JMP, not just the one you happen to be working on. You can always go back and change it in Preferences if you want.

 

  Or, once you get the graph looking like you want, you can always right click a spectrum of choice and then select Line Color, and choose any preset color shown, or even Other... from a larger color palette. But, this can be slow if you have lots of spectra.

SDF1_5-1699538373770.png

 

  There's lots of ways to get the same things accomplished in JMP, which is great, and it kind of depends on what you're specific needs are and what your end goal is as to which method might work out better.

 

Hope this helps!,

DS

 

txnelson
Super User

Re: Graph Builder: How to make stacked plots with some displacement for each series

Are the replicates exact replicates of each other?

Jim
ehchandlerjr
Level V

Re: Graph Builder: How to make stacked plots with some displacement for each series

@txnelson In my case, I have about 50 variables that I could use as defining of the series of series. Those two in the picture I shared I think are true replicates, but what I'm looking for wouldn't require two entire rows to be identical to be matched.

 

I guess if I had to design it, it would maybe have a drop box for a "series" variable, to test whether any series should be matched (and show up closer or not). I suppose this series variable should also have the ability to color the points, or change the size, or something else. And then maybe a slider to adjust the scale factor @hogi mentioned for the gap between the two.

 

I'm pretty sure what I just described isn't possible currently in JMP, so ... XY problem with that wishlist I just gave, but hopefully that clears up what I'm looking for and maybe there's some GUI way to do it? If not, @hogi's method would work.

Edward Hamer Chandler, Jr.
SDF1
Super User

Re: Graph Builder: How to make stacked plots with some displacement for each series

Hi @ehchandlerjr ,

 

  Here is some JSL code that will do part of the job -- it easily adds a fixed offset to each spectra and it adds the same amount to each additional spectra. So for the first spectrum, there is no offset, but then each additional spectrum, they get an offset of n*5000, I used 5000 in my case -- I used the NMR DoE.jmp sample data table and transposed it to get columns of spectra, which is I'm guessing how your data table is structured rather than rows as spectra and columns as wavelengths. Anyway, you should be able to modify this code to work best for your data structure and data tables. I'm attaching the code and modified sample data table so you can see. Here are the results. You can then go in manually and edit the offset for any replicates or specific spectra that you need to.

 

  The top graph is without an offset and the bottom graph is with an offset. Color coding is automatic by JMP.

SDF1_1-1699473771043.png

 

  Here's the code:

Names Default To Here( 1 );

dt = Current Data Table(); //assigns current data table to variable dt

ColNames = dt << Get Column Names; //gets a list of column names

offset = 5000; 

//This generates a new column for each spectra with the column name + Offset to it
For( i = 2, i <= N Items( ColNames ), i++,
	If( i == 2,
		offset = 0, // no offset for the first spectrum
		offset = 5000 //offset amount for each additional spectrum
	);
	Eval( Eval Expr( dt << New Column( Colnames[i] || " Offset", Formula( Expr( As Name( ColNames[i] ) ) + (Expr( (i - 2) * offset )) ) ) ) ); //the (i-2) is so the second spectrum is offset only by 5000 and not 10000
);

  A slow, but surefire way would be to create new columns and manually generate the formula for each column, but it would work the same.

 

Hope this helps!,

DS