[Script JLS] : Loop for plotting several graphs togetherHello,
I'm new in JMP. It's a powerfull software !
That is why I would like to write a script that can plot several Y from different column (every n column actually) in function of one X.
I wrote it thanks to graph builder interface, but I would like to script it in a loop.
I did something like that for plotting distribution (but it is not the same scale unfortunately ...)
//Distributions Std Dev
New Window( "Side by Side",
H List Box(
Distribution(
Continuous Distribution( Column( :median_range_mm ))
);
for ( p = 2, p <= 64, p++,
nom = "median_range_mm " || char(p);
col = Column(nom);
Distribution(
Continuous Distribution( Column( col ), Std Error Bars( 1 ) );
/*SendToReport(
Dispatch(
{"Distributions", Column( col )},
"1",
ScaleBox,
{Min( 1450 ), Max( 1820 ), Inc( 20 ), Minor Ticks( 0 ),
Label Row Nesting( 1 )}
)
)*/
)
)
)
This is what I tried for my main problem, the result is just an opening window of graph builder.
I would like to plot the column [ref, ref 1 , ref 2 until ref 64] on Y axis and currentTimeMillis on X axis
New Window( "Ref",
H List Box(
Graph Builder(
For (r = 2 , r <= 64, r++,
name = "ref " || char(r);
col = Column(name);
Variables( X( :currentTimeMillis ), Y (Column (col), Position( 1 ) ) ),
Elements(
Points( X, Y(r) , Legend( 29 ) ),
Smoother( X , Y(r), Legend( 30 ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( strTitle )}
)
)
)
)
)
);Thanks for your help.
Cheers
Re: [Script JLS] : Loop for plotting several graphs togetherOne can easily create output objects, that can be created in advance and then displayed at user's request. Or, because of the speed of JMP, many of my applications generate specific outputs at the time of a user's request. You should also explore the Column Switcher that will allow the user to select from a list, what to columns to analyze and display.
Re: [Script JLS] : Loop for plotting several graphs togetheris that possible to save individual graph(like easy access list) for later use instead of plot them all in a single H List Box? thank you.
Re: [Script JLS] : Loop for plotting several graphs togetherI am a bit confused.....but I offer this code as a possible example of a solution. It appears from the last piece of code you supplied, that you are changing the names of columns in your data table, to "Ref". Since JMP will not allow you to have 2 columns of the same name, the second column you attempt to rename "Ref", actually gets named, "Ref 2". And that continues all the way through column "Ref 64". I also suggest that you recheck your code for the naming of column "currentTimeMillis". In your code, you actually rename that column(to the same name), 64 times.
Below is my new code......it uses a sample data table.......the columns called Ref - Ref 64, are all in a contiguous order, but since JMP really does not care, the code will also work for your data table, where the columns are spread across your 700+ columns
Names Default To Here( 1 );
// Build some sample data
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Column( dt, 6 ) << set name( "ref" );
For( i = 7, i <= 69, i++,
Column( dt, i ) << set name( "ref " || Char( i - 5 ) )
);
Column( dt, 5 ) << set name( "currentTimeMillis" );
// Build the JSL code for the Graph Builder
theExpr = "dt << Graph Builder(
Variables(
X( :currentTimeMillis ),
Y( :ref )";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( :ref " || Char( i ) || ", Position( 1 ) )"
);
theExpr = theExpr || "),
Elements(
Points(
X";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( " || Char( i ) || ")"
);
theExpr = theExpr || "
,Legend( 5 )
),
Smoother(
X";
For( i = 2, i <= 64, i++,
theExpr = theExpr || ",Y( " || Char( i ) || ")"
);
theExpr = theExpr || " ,
Legend( 6 )
)
)
)";
// Execute the generated code
Eval( Parse( theExpr ) );
Re: [Script JLS] : Loop for plotting several graphs togetherThank you for your reply Jim !
But I may have misrepresented my problem.
Indeed, I would like to have all of my plot on the same graph.
Also my Y column has already been set every 11 columns, and currentTimeMillis appear just once at the beginning :
//Set columns
For( i = 1, i <=709 , i++,
For ( j = 0, j <= 63, j++,
If ( i == 2, Column(i) << set name( "currentTimeMillis" ),i == 15 + 11*j, Column(i) << set name( "ref" ),
)
)
)Finally, "__col__" has not been defined ( "col" was defined but in an other function for distribution), so I don't understand why you used it here.
Thanks again.
Re: [Script JLS] : Loop for plotting several graphs togetherHere is an example of how I would do it
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
For( i = 6, i <= 69, i++,
Column( dt, i ) << set name( "ref " || Char( i - 5 ) )
);
Column( dt, 5 ) << set name( "currentTimeMillis" );
New Window( "Ref",
hlb = H List Box(
)
);
For( r = 2, r <= 64, r++,
name = "ref " || Char( r );
Eval(
Substitute(
Expr(
outputhlb = H List Box(
Graph Builder(
Variables(
X( :currentTimeMillis ),
Y( Column( __col__ ), Position( 1 ) )
),
Elements(
Points( X, Y( r ), Legend( 29 ) ),
Smoother( X, Y( r ), Legend( 30 ) )
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( strTitle )}
)
)
)
)
),
Expr( __col__ ), Parse( ":" || name )
)
);
hlb << append( outputhlb );
);