Thanks @Jed_Campbell for this elegant solution.
What a brilliant idea to use a dummy variable on the second Y axis and a bar graph to switch the shading on and off.
Then the user has still all the flexibility in the original graph.
Alternative approach:
Use the dummy variable as color for a Heatmap, like @John_Powell_JMP suggested some years ago for a similar task:
https://community.jmp.com/t5/Discussions/background-color-of-graph-builder/m-p/36095/highlight/true#...
The disadvantage: one has to fiddle around with the variables (no Y variable for the Heatmap, don't use the Color/dummyVariable for the main plot)
The benefit: one doesn't have to fiddle around with the second axis (remove the grid lines etc)
Which approach is better?
Depends on the application case.
If there is just a single weekend to be shaded, a reference line on the X axis can also do the job ;).
@dale_lehman
I am curious which of the three solutions you had in mind when posting the question - or even better: a fourth one?
Nevertheless, thanks for the question which added a wonderful solution to the community collection.
Graph Builder(
Size( 937, 401 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Summary Statistic( "Median" ),
Graph Spacing( 4 ),
Variables( X( :Month Code ), Y( :"Mean(Deaths, White)"n ), Color( :Dummyvar ) ),
Elements( Heatmap( X, Legend( 37 ) ), Points( X, Y, Color( 0 ), Legend( 38 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
37,
Properties( 0, {Transparency( 0.2 )}, Item ID( "Dummyvar", 1 ) )
)}
)
)
);