<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi,
I'm almost completely new to JSL, so excuse me if my question appears trivial...
Anyway, I am dealing with a data table that contains processed spectroscopic data, with each line corresponding to one specific spectroscopic XY dataset that are each located in separate .txt files. Now, I want to dynamically generate overlay plots of the raw datasets corresponding to the currently selected cells/rows.
For example, I select rows 2 and 3 and the script opens both corresponding .txt files, updates them into a new temporary data table and generates the overlay plot with the 2 data series. Next time I select rows 6 to 9, and of course now the resulting overlay plot should contain 4 series of data.
My script to do all this works fine up to the point of actually generating the overlay plots in a dynamic fashion.
Simplified, generating the plot looks like this:
Overlay Plot(
X( :Name( "cm-1" ) ),
Y(
parse(plot1),
parse(plot2),
parse(plot3)
),
Connect Points( 1 ),
Show Points( 0 ),
);
With the variables plot1 etc. corresponding to columns in the temporary data table. However, the amount of data series is fixed in this example (3) - and that's where I'm stuck. Can I somehow make that dynamic? So basically have the script change the amount of Y's depending on the number of selected cells/rows?
e.g. Y(parse(plot1)) if there's only one, Y(parse(plot1),parse(plot2),parse(plot3),parse(plot4)) if there is 4?
The plot# variables are already being generated dynamically based on the amount of selected rows. So all I need really is a way to dynamically have the number of entries in the Y() expression correspond to the number of selected rows.
Any help would be highly appreciated!
Wow that was fast! It works, great!
Thanks a lot, it is appreciated!
cheers!
Use a list of Y columns: Y(list) or Y(eval(list)). For example:
dt = Current Data Table(); // Temp data table
n1 = 2; // number of originally selected rows
n2 = N Col( dt ); // total number of cols in dt
Overlay Plot(
X( :Name( "cm-1" ) ),
Y( (dt << get column names)[n2 - n1 + 1 :: n2] )
// List of Y columns, assuming they are at end of Temp table
);