cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
wr
wr
Level II

Graph builder scripting - changing graph properties

I am trying to change properties such as color/size/transparency of both markers and lines on overlaid graphs using scripts (tied to user inputs like check boxes and text boxes). Below is code I was playing with to try and figure how to manipulate the script, but not sure that I know what I am doing :-). If you know answers to questions in comment lines of the code or if you know a syntax reference exists for gb functions, please post...Thanks...

//Create table

dt = New Table("grphbldr.jmp", Add Rows(10),

       New Column("X", Numeric, Continuous, Set Values(1::10)),

       New Column("Y1", Numeric, Continuous, Formula(:X^2)),

       New Column("Y2", Numeric, Continuous, Formula(3*:X^2-100)),

);

gb = Graph Builder(

       Show Control Panel( 0 ),

       //Syntax to clear variables and new ones?

       //what is Position(1)?

       Variables( X( :X ), Y( :Y1 ), Y( :Y2, Position( 1 ) ) ),

       //information/syntax about Elements, Legend?

       //Why doesn't a legend show for Y(2) points on graph?

       Elements(

              Points( X, Y( 1 ), Y( 2 ), Legend( 1 ), Jitter( 1 ) ),

              Line(

                     X,

                     Y( 1 ),

                     Y( 2 ),

                     Legend( 2 ),

                     //Info about Row order?

                     //Draws lines through missing points?

                     Row order( 0 ),

                     Summary Statistic( "Mean" )

              )

       ),

       SendToReport(

       //what is "400"?

              Dispatch( {}, "400", ScaleBox,

                     {

                     //change transparency of points.

                     //Legend Model(1) for points. Properties(0) - for Y1,

                     //and Properties(1) for Y2?

                     //How to set marker type and size for points?

                     Legend Model( 1 , Properties( 0, {Transparency( 0.6 )} ) ),

                     Legend Model( 1 , Properties( 0, {Transparency( 0.4 )} ) ),

                     //change transparency and line thickness of lines.

                     //Legend Model(2) for lines. Properties(0) - for Y1,

                     //and Properties(1) for Y2?

                     Legend Model( 2 , Properties( 0, {Line Width(2), Transparency( 0.6 )} ) ),

                     Legend Model( 2 , Properties( 1, {Line Width(5), Transparency( 0.4 )} ) )

                    

                     }

              )

       )

);

1 ACCEPTED SOLUTION

Accepted Solutions
XanGregg
Staff

Re: Graph builder scripting - changing graph properties

Looks like you've figured out most of it. Follow PMRoz's suggestions for the example syntax for getting marker and marker size into the legend properties.

//what is Position(1)?

If you two Ys they can either go in two "positions" or both in the same position. Position(1) says to put the 2nd Y in the same position as the first Y.

       //Why doesn't a legend show for Y(2) points on graph?

     

This may be a bug or at least a deficiency in a heuristic. GB tries to hide "unnecessary" legend items such as when the points and the lines are the same color. Same goes for regression lines and their confidence intervals.

       //what is "400"?

400 is fixed GB id number for the legend.

You can think of the whole Send To Report() part as an addendum to the GB script, making display modifications after the graph model has been built.

View solution in original post

3 REPLIES 3
pmroz
Super User

Re: Graph builder scripting - changing graph properties

Rather than trying to understand the syntax of graph builder, I take a different approach:

I create the graph using graph builder and manipulate it until it's exactly how I want it.  Then I click the red triangle and copy the script and put it into my JSL program.

XanGregg
Staff

Re: Graph builder scripting - changing graph properties

Looks like you've figured out most of it. Follow PMRoz's suggestions for the example syntax for getting marker and marker size into the legend properties.

//what is Position(1)?

If you two Ys they can either go in two "positions" or both in the same position. Position(1) says to put the 2nd Y in the same position as the first Y.

       //Why doesn't a legend show for Y(2) points on graph?

     

This may be a bug or at least a deficiency in a heuristic. GB tries to hide "unnecessary" legend items such as when the points and the lines are the same color. Same goes for regression lines and their confidence intervals.

       //what is "400"?

400 is fixed GB id number for the legend.

You can think of the whole Send To Report() part as an addendum to the GB script, making display modifications after the graph model has been built.

pmroz
Super User

Re: Graph builder scripting - changing graph properties

Just want to add that I have done some extensive manipulation of GB commands, but only after working out a complex graph and looking at the code.  I wanted to set my own markers and colors, and show lines connecting symbols, but I only wanted the legend to show the symbols, not the lines.  Once you create a complex example graph you can look at the code and figure out how to recreate it dynamically for other situations (i.e. differing number of things to plot).

There's logic to the GB code but the safest thing to do is create it using GB.