Subscribe Bookmark RSS Feed

Shading in an area on a time-series chart

scottahindle

Occasional Contributor

Joined:

May 18, 2017

Dear all,

If I plot a simple time-series of my data I will often gain insight from control limits and also spec limits on the graph. (Simple visualisations of the Voice of the Process and the Voice of the Customer).

With control charts we can "Shade Zones" which can help - I like this feature.

Is there a simple way to do something similar using Graph Builder?

In the attached file it is easy enough to add a pair of horizontal lines which you find at -3 and +3. Is there a simple way using scripting to shade in between two such horizontal lines? How would I shade in the area between -3 and +3 on such a graph to show this is a region to focus on when making sense of the data?

Would be great if somebody could pass on some advice.

Scott.

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

Through JSL you can add a graphics script to customise the graph, so that it shows a shaded polygon:

gb = Graph Builder(
	Size( 1659, 932 ),
	Show Control Panel( 0 ),
	Variables( X( :Series ), Y( :Data ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Series",
			ScaleBox,
			{Min( 0 ), Max( 102 ), Inc( 10 ), Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Data",
			ScaleBox,
			{Min( -4 ), Max( 4 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 3, "Solid", "Black", "", 1 ),
			Add Ref Line( -3, "Solid", "Black", "", 1 )}
		)
	)
);

// create a shaded region
rep = gb << Report;
x = {};
x[1] = rep[AxisBox(1)] << Get Min;
x[2] = rep[AxisBox(1)] << Get Max;
x[3] = x[2];
x[4] = x[1];
y = {-3,-3,3,3};
fb = rep[FrameBox(1)];
fb << Add Graphics Script(
	Transparency(0.1);
	Fill Color("Green"); 
	Polygon( Matrix(x), matrix(y) )
);

 

-Dave
5 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

Through JSL you can add a graphics script to customise the graph, so that it shows a shaded polygon:

gb = Graph Builder(
	Size( 1659, 932 ),
	Show Control Panel( 0 ),
	Variables( X( :Series ), Y( :Data ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Series",
			ScaleBox,
			{Min( 0 ), Max( 102 ), Inc( 10 ), Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Data",
			ScaleBox,
			{Min( -4 ), Max( 4 ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 3, "Solid", "Black", "", 1 ),
			Add Ref Line( -3, "Solid", "Black", "", 1 )}
		)
	)
);

// create a shaded region
rep = gb << Report;
x = {};
x[1] = rep[AxisBox(1)] << Get Min;
x[2] = rep[AxisBox(1)] << Get Max;
x[3] = x[2];
x[4] = x[1];
y = {-3,-3,3,3};
fb = rep[FrameBox(1)];
fb << Add Graphics Script(
	Transparency(0.1);
	Fill Color("Green"); 
	Polygon( Matrix(x), matrix(y) )
);

 

-Dave
scottahindle

Occasional Contributor

Joined:

May 18, 2017

David - Thanks!

jerry_cooper

Staff

Joined:

Jul 10, 2014

As a non-scripting alternative for those with JMP version 12 or higher, there is an option for allowing ranges for reference lines in the Y-axis Settings dialog (double-click the y-axis). Checking the "Allow Ranges" box will provide number boxes for inputting the min and max of the range and will allow you to choose a color for that range.
David_Burnham

Super User

Joined:

Jul 13, 2011

Nice one Jerry, not seen that check box before.

The code example that I provide I usually use for confidence intervals, but for a rectangular range, like you said can be done interactively, or can be done like this:

rep = gb << Report;
rep[AxisBox(2)] << Add Ref Line( {-3, 3}, "Solid", "Medium Light Green", "", 1, 0.25 );
-Dave
scottahindle

Occasional Contributor

Joined:

May 18, 2017

Thanks, Jerry. This is a great option which I didn't know about. I've already used it a few times!