Highlighted
Level IV

## Shading in an area on a time-series chart

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
Highlighted
Super User

## Re: Shading in an area on a time-series chart

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 )}
)
)
);

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)];
Transparency(0.1);
Fill Color("Green");
Polygon( Matrix(x), matrix(y) )
);
``````

-Dave
5 REPLIES 5
Highlighted
Super User

## Re: Shading in an area on a time-series chart

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 )}
)
)
);

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)];
Transparency(0.1);
Fill Color("Green");
Polygon( Matrix(x), matrix(y) )
);
``````

-Dave
Highlighted
Level IV

David - Thanks!

Highlighted
Staff (Retired)

## Re: Shading in an area on a time-series chart

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.
Highlighted
Super User

## Re: Shading in an area on a time-series chart

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
Highlighted
Level IV

## Re: Shading in an area on a time-series chart

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

Article Labels

There are no labels assigned to this post.