cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Piet_Hoogkamer
Level III

Repeat legend with every page

When a graph is created (in Graph Builder) with multiple pages, using one of the variables as a page parameter, the legend is only shown for the first page.

How to repeat the legend for all pages?

Any suggestion much appreciated!

Piet
15 REPLIES 15
JDW
JDW
Level II

Re: Repeat legend with every page

I'm having the same problem in JMP 15. I use graph builder and create multiple graphs by dropping a variable in the "Page" box; but the legend only shows up on the first graph. How were you able to resolve this?

Piet_Hoogkamer
Level III

Re: Repeat legend with every page

Please have a look at the solution posted by Julian: start in graph builder with dialog and then use the by option instead of the page option for your grouping variable.

Piet
Piet_Hoogkamer
Level III

Re: Repeat legend with every page

Hello,

The trick is to use the DIALOG option to start making a graph.
When you open the graph builder, you will see this option.
Rather than using the PAGE option for your grouping variable, use the BY option instead.
Please make sure that in the DIALOG box the legend variable is selected for OVERLAY or COLOR.

Piet
JDW
JDW
Level II

Re: Repeat legend with every page

Thank you. I had never used the dialog option before to start a graph.
KurtAnderson
Level III

Re: Repeat legend with every page

This is beautiful.  However, I have two issues.

1. The x-axis categories for my Pages (using the "By" command) are not always the same, as I would like them to be.  Specifically, I'm using "Year Quarter" as ordinal x-axis.  So if one page does not have data in 2022-Q4, but another page has no data in 2022-Q2 and 2023-Q1, the axes from page to page are not the same.  I can work around this by entering zero as my continuous data for a given category, but that's NVA.  Can we force the x-axes to be the same on every page (it seems this is the default when "Page" is used instead of "By").

2.  If a legend category is not used on a page, it does not appear in the legend.  Again, I'd like the legend on all pages to be identical.  "By" is certainly superior to "Page" in this regard, but it would be even better if the legends could be forced to be identical.  In my case, my y-axis continuous data are lost hours of production for a manufactuing process.  I'm using a stacked bar.  My categories for the legend ("Overlay") are loss reasons (e.g. "Not following procedure", "Corrosion", "Rotating equipment failure", "Raw material shortage").  The advantage to having the legend identical, even if a particular category is not present, is that it reinforces to the audience that in fact this cause is ZERO on this Page, whereas it is non-ZERO on another page.

hogi
Level XII

Re: Repeat legend with every page

Hm, how bad that the cool features are evenly split between Page and By - and not grouped ...

 

For 1, I also used some dummy rows to span the grid (and more severe: Group X/Y grid of FrameBoxes) similarly in all By-Plots.

 

For2, it helps to define Value Colors for the Overlay Column. Then all By-Graphs will automatically share the same color coding - and vice versa, the audience can easily get from the legend that one cause was ZERO on the page.
If you want to have exactly the same legend, you could also add some dummy rows to fill the legends.

Due to the dummy row, age=17 (with just "M") gets the same legend as age=12:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << << Select Rows( [38] ) << Delete Rows;

dt << Add Rows( {age = 17, sex = "F"} ); // dummy entry to get the legends aligned

Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
	By( :age ),
	Where (:age ==12| :age==17)
);