cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
qunw
Level III

Sankey Plot Color Assignment

Hi JMP Community, 

Do you have any experience assigning the color for all sequences in a Sankey Plot with the SAME color category?   The challenge I encountered was that each sequence had a different color category, making it difficult to track the change of items from sequence 1 to 2... to n with the same color assigned. 

Many thanks!

 

 

13 REPLIES 13
Victor_G
Super User

Re: Sankey Plot Color Assignment

Hi @qunw,

Welcome in the Community !
I think Parallel Coordinates Plot could be helpful for your objective, with the color coding by category. See more here https://www.jmp.com/support/help/en/18.2/#page/jmp/parallel-plots.shtml

You can also check the Enhanced Sankey Plot (ESP) created by @jthi : https://community.jmp.com/t5/JMP-Add-Ins/Enhanced-Sankey-Plot-ESP/ta-p/549745


Hope these options will help you,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
hogi
Level XII

Re: Sankey Plot Color Assignment

Hi @qunw , Could you please post an (anonymized) example of the issue you experience?

 

On my side, I wish I could use Sankey plots to monitor state changes - of "properties" during a process flow.
e.g. with different categories of pass and fail.

 

In a Sankey plot, color doesn't indicate the value per category, it indicates "groups". (red on the left of the diagram are the same rows of the data table as red on the right - anywhere else in the plot.) Is this what you describe with "each sequence had a different color category"?

 

As a consequence - in the below example, e.g. blue can "be" 0 on the left, and blue in the center and on the right:
hogi_0-1753384460266.png

 

On the other hand, from how the plot works, it doesn't make sense to give all "1"s with the same color.

 

But how to "find" the 1s in a complicated Sankey plot.
If they don't have the same color?

Unfortunately: JUST BY THE LABELS !

 

And how to find "state" changes - e.. from 0 to 1. -> close to impossible "by the naked eye" - it just works with heavy load on the brain-coprocessor:


Different to a Sankey plot for continuous values:

hogi_1-1753384945218.png
... for columns with nominal modeling type the same value can be at rather different positions along the Y axis.
This makes it very hard to detect "state" changes for Sankey plots with nominal values.

There could be an option to switch from the nominal mode to a quasi "continuous mode" - with same values on the same height - but with the cool additional feature to track "population" by the width of the "tubes"

There is a wish to enable this mode: Parallel Plot: synchronized axes 

 

The workaround at the moment:
use (pseudo-)continuous values.

hogi
Level XII

Re: Sankey Plot Color Assignment

Beside the usability - there is also an aesthetic aspect:

why do Savings, Home and other bend upwards - why not stay on one height?
There is enough (empty) space at the lower right:

hogi_0-1753386154040.png

 

qunw
Level III

Re: Sankey Plot Color Assignment

I learned this graph from a community post, which provided another way of visualizing a related question, such as tracking the diversity of each regimen in the initial treatment and subsequent treatments. I figured out a way to generate it by labeling each value in the following Outflows with the value in Outflow 1 as the prefix if they are from the same value in Outflow 1, such as 'Auto', 'Home', 'Taxes', etc. This requires some data preprocessing to make it happen.  Hope you have a better way to do it.  Many thanks!

qunw
Level III

Re: Sankey Plot Color Assignment

Thanks so much, Hogi, for helping me with this query and sharing the examples!  I used the Sankey plot for patient treatment profiling and tried to assign the same colors to the same regimens in the sequence of treatments.  My case is quite similar to your example.  You were correct about my description of "each sequence had a different color category."  The "value 1, 2 and 3" on x-axis like "treatment 1, 2, and 3", and "value 0, 1, 2" like regimens per treatment.   I would like to synchronize the color setting of 0, 1, and 2 in each "value 1, 2, and 3", where "1" is red, "2" is green, and "0" is blue across value 1, 2, and 3.  So that will help to understand the patients' treatment journey. Please let me know if you have any solution for it—many thanks. 

 

qunw_0-1753764893903.png

 

hogi
Level XII

Re: Sankey Plot Color Assignment


@qunw wrote:

 I would like to synchronize the color setting of 0, 1, and 2 in each "value 1, 2, and 3", where "1" is red, "2" is green, and "0" is blue across value 1, 2, and 3.  


Ok, understood.

I fear, this is not possible (and not intended) via Sankey plot.

hogi
Level XII

Re: Sankey Plot Color Assignment

In GraphBuilder, colors can be assigned via Row States or the Color Dropzone.
In both cases, the color is defined 'by row'.


Therefore, when you select a trajectory in the plot, a specific row is selected. The color of the trajectory is defined by the color of this row. One trajectory, one color.

hogi_3-1753768025975.png

 

View more...
New Table( "treatment",
	Add Rows( 9 ),
	New Column( "patient",
		Character,
		Set Values(
			{"V1_0", "V1_1", "V1_2", "V1_3", "V1_4", "V1_5", "V1_6", "V1_7", "V1_8"}
		)
	),
	New Column( "treatment 1",
		"Nominal",
		Set Values( [1, 1, 1, 2, 2, 2, 3, 3, 3] )
	),
	New Column( "treatment 2",
		"Nominal",
		Set Values( [1, 2, 3, 1, 2, 3, 1, 2, 3] )
	),
	New Column( "treatment 3",
		"Nominal",
		Set Values( [1, 1, 2, 1, 2, 3, 3, 3, 3] )
	)
)
hogi
Level XII

Re: Sankey Plot Color Assignment

to get different colors for the same row, one has to use scripting - or split the row.

 

Split the row: Stack the table:

current data table << Stack(	columns( :treatment 1, :treatment 2, :treatment 3 ));

Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :Label ), Y( :patient ), Color( :Data ) ),
	Elements( Heatmap( X, Y, Legend( 4 ) ) )
);

 

hogi_4-1753768778572.png

 

hogi
Level XII

Re: Sankey Plot Color Assignment

The Heatmap plot contains all the information - but: it is surprising how many co-processing by the human brain in needed to "understand it".

 

Closer to the Sankey plot - with treatment indicated by color AND position along the y axis.
-> less coprocessing needed - much easier to see the information by the naked eye.

hogi_7-1753770463548.png   hogi_0-1753778310430.png

 

 

Even closer to Sankey -- with all trajectories in one plot, 

the graph gets very busy and it's not possible anymore to follow specific trajectories.

hogi_6-1753770052194.png

Recommended Articles