cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Prokaryote
Level II

How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

I've highlighted a legend box that contains 2 legend models.  I'd like to put the first legend model in a stand alone legend box and place that legend box in the first framebox.  For the second legend model, I'd like to put it in a stand alone legend box and place that second legend box in the second framebox.  Is this possible by manipulating the graphbuilder script? 

Thanks!

 

ih_0-1684351521207.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

You can script this with images but they are just images

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
gb = dt << Graph Builder(
	Size(900, 600),
	Show Control Panel(0),
	Show Legend(1), // left here to check correct colors
	Graph Spacing(20),
	Variables(
		X(:lot_id),
		Y(:NPN1),
		Y(:PNP1, Position(1)),
		Y(:PNP2, Position(1)),
		Y(:NPN2),
		Y(:PNP3, Position(2)),
		Y(:IVP1, Position(2))
	),
	Elements(Position(1, 1), Smoother(X, Y(1), Y(2), Y(3), Legend(3))),
	Elements(Position(1, 2), Smoother(X, Y(1), Y(2), Y(3), Legend(4)))
);

Report(gb)[LegendBox(1)] << Legend Position({3, [0, 1, 2], 4, [-1, -1, -1]});
lgnd_img1 = Report(gb)[LegendBox(1)] << get picture;

Report(gb)[LegendBox(1)] << Legend Position({3, [-1, -1, -1], 4, [0, 1, 2]});
lgnd_img2 = Report(gb)[LegendBox(1)] << get picture;

Report(gb)[FrameBox(1)] <<Add Image(image(lgnd_img1), Move(11.5, 650));
Report(gb)[FrameBox(2)] <<Add Image(image(lgnd_img2), Move(11.5, 150));

Report(gb)[LegendBox(1)] << Legend Position({3, [0, 1, 2], 4, [3, 4, 5]}); // // left here to check correct colors
-Jarmo

View solution in original post

12 REPLIES 12
Phil_Kay
Staff

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

I'm not sure if this will be possible. I don't know if you can have 2 different legend boxes. Hopefully some of our JMP Community scripting experts can help (not me!). It could help if you are able to be more specific about what you are trying to achieve. I don't understand what differentiates the 2 legend boxes. Or why you need them to be separate. Attaching a jmp data example would be good.

Prokaryote
Level II

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

Hi @Phil_Kay , thank you for your reply.  An answer to the second question that you asked above is suppose you had multiple graphs with the same X axis (different y-axes) on two or more pages.  Instead of having to scroll to the top of each page to see the legend, one could just past the legend pertinent to each graph to each graph's framebox or scalebox.

Screenshot 2023-05-16 at 9.53.16 AM.png

Screenshot 2023-05-16 at 9.53.31 AM.png

  Also, the individual graphs may take up the whole screen and again, it would be nice to have the appropriate legend for each graph within that graph's scale or frame box.  I looked at the tree structure and it looks like the legend box is appended to the scalebox with the name/handle? "400".  The way we deal with it now is to create a slide and copy the edited legend (so that it shows just the parameters of interest) and paste it onto its respective graph.  Does this help?  Thanks, Prok.

Prokaryote
Level II

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

oops, I meant instead of having to scroll to the top of page 1... instead of the top of each page.  Sorry.

Prokaryote
Level II

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

 

Here's the script that generates the graphs above, note the scalebox "400".

Screenshot 2023-05-16 at 10.18.45 AM.png

 I opened the tree structure and looked for the properties of the scale box, but was unable to find properties for the scalebox.  You can see that it skips over the pictureBox(1), goes to the GraphBuilderBox(1)

Screenshot 2023-05-16 at 10.23.41 AM.png

 And when expanding the GraphBuilderBox(1), it skips over the ScaleBox and the ParallelScaleBox(1) and goes right to the GraphBuilderContainerBox(1), skips the GraphBuilderComponentBox(1), etc...

Screenshot 2023-05-16 at 10.29.23 AM.png

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

One way to get a legend showing up on each graph is to use the dialog box for graph builder (Red Triangle...Redo..Relaunch), and switch the Page variable to the By section. Credit to @julian from this post. Screenshot below:

Jed_Campbell_0-1684342996008.png

 

Prokaryote
Level II

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

Hi @Jed_Campbell, sorry for the long delay in getting back to you.  I think that the answer kind-of works, in that we can get a legend on each page:  I'm not sure what to do though if we have on the 'Y' axis say 4 different parameters that one is plotting, how would one paginate these?  Would stack the parameter columns as say 'data' then use the 'label' column as a page demarcation?  Would be hard to have an easy comparison of the 4 'Y' parameters to compare against each other with respect to the X axis, I guess you'd have to jump from page to page.  

 

I'm guessing that Graph Builder is not set up architecturally to have a legend box per graph frame then?

 

Thanks,

prok.

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

I think the same trick works, as long as I'm understanding you correctly. Here's a graph with 4 different variables on the Y axis (file attached).

Jed_Campbell_0-1685632362780.png

 

Prokaryote
Level II

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

Hi @Jed_Campbell, Almost, except that dividing a single Y axis into say 3 graphs, each with a different Y scale...

Screenshot 2023-06-01 at 10.54.37 AM.png

hogi
Level XI

Re: How do I create 2 or more legend boxes in Graph Builder and place each in the respective framebox/scalebox?

Any new findings here?